diff --git a/.gitignore b/.gitignore index e4333bb..4e7fe8a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json .DS_Store .turbo + +tmp.* \ No newline at end of file diff --git a/package.json b/package.json index 0b6f4e4..ea7f062 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "winos-config", "version": "0.0.1", - "module": "index.ts", "type": "module", "private": true, "packageManager": "bun@1.3.3", @@ -24,7 +23,6 @@ "@biomejs/biome": "2.3.8", "@effect/language-service": "^0.57.1", "@types/bun": "latest", - "quicktype": "^23.2.6", "turbo": "^2.6.1", "typescript": "^5.9.3", "ultracite": "6.3.8" diff --git a/scripts/gen-dsc-resources-types.ts b/scripts/gen-dsc-resources-types.ts index 3f4e5bb..2989fa0 100644 --- a/scripts/gen-dsc-resources-types.ts +++ b/scripts/gen-dsc-resources-types.ts @@ -1,24 +1,120 @@ import { Command, FileSystem, Path } from '@effect/platform'; import { BunContext, BunRuntime } from '@effect/platform-bun'; -import { Effect, Logger, LogLevel } from 'effect'; -import { jsonSchemaToEffectSchema, runCommand } from './lib/script-utils'; +import { Effect, Logger, LogLevel, Schema as S } from 'effect'; +import { jsonSchemaToEffectSchema } from './lib/script-utils'; -const getDscResourceJsonSchema = (resourceType: string) => +// Schema for DSC resource list output +const DscResourceSchema = S.Struct({ + type: S.String, + kind: S.String, + version: S.String, + capabilities: S.Array(S.String), + path: S.String, + description: S.NullOr(S.String), + directory: S.String, + manifest: S.Struct({ + $schema: S.String, + type: S.String, + version: S.String, + description: S.optional(S.NullOr(S.String)), + schema: S.optional( + S.NullOr( + S.Union( + S.Struct({ + command: S.Struct({ + executable: S.String, + args: S.NullOr(S.Array(S.String)), + }), + }), + S.Struct({ + embedded: S.Unknown, + }), + ), + ), + ), + }), +}); + +type DscResource = S.Schema.Type; + +/** + * Sanitize a resource type name to be a valid TypeScript identifier and filename + * e.g., "Microsoft.WinGet/Package" -> "MicrosoftWinGetPackage" + */ +const sanitizeTypeName = (resourceType: string): string => { + return resourceType + .replace(/[/\\]/g, '') // Remove slashes + .replace(/\./g, '') // Remove dots + .replace(/[^a-zA-Z0-9]/g, ''); // Remove any other invalid chars +}; + +/** + * Convert resource type to a safe filename + * e.g., "Microsoft.WinGet/Package" -> "microsoft-winget-package" + */ +const toSafeFilename = (resourceType: string): string => { + return resourceType + .replace(/[/\\]/g, '-') // Replace slashes with hyphens + .replace(/\./g, '-') // Replace dots with hyphens + .toLowerCase(); +}; + +/** + * Get schema for a DSC resource - either from embedded schema or via `dsc resource schema` + */ +const getDscResourceSchema = (resource: DscResource) => Effect.gen(function* () { - const commandParts = [ - 'dsc', - 'resource', - 'schema', - '--resource', - resourceType, - ] as const; - yield* Effect.logDebug(`Running command: ${commandParts.join(' ')}`); - const schemaString = yield* Command.make(...commandParts).pipe( - Command.string, - ); - return schemaString.trim(); + const schema = resource.manifest.schema; + + if (!schema) { + yield* Effect.logDebug(`No schema defined for ${resource.type}`); + return null; + } + + // Check if it's an embedded schema + if ('embedded' in schema) { + yield* Effect.logDebug(`Using embedded schema for ${resource.type}`); + return JSON.stringify(schema.embedded); + } + + // Otherwise, use dsc resource schema command (more reliable than running executable directly) + if ('command' in schema) { + yield* Effect.logDebug(`Getting schema via DSC CLI for ${resource.type}`); + + const schemaString = yield* Command.make( + 'dsc', + 'resource', + 'schema', + '--resource', + resource.type, + ).pipe(Command.string); + + return schemaString.trim(); + } + + return null; }); +/** + * Parse NDJSON output (newline-delimited JSON) from dsc resource list + */ +const parseNdjson = (output: string): Array => + output + .split('\n') + .map((line) => line.trim()) + .filter((line) => line.length > 0) + .map((line) => { + try { + return JSON.parse(line); + } catch { + return null; + } + }) + .filter((obj): obj is unknown => obj !== null); + +/** + * Get available DSC resources from the system + */ const getAvailableDscResources = () => Effect.gen(function* () { yield* Effect.logDebug('Getting available DSC resources...'); @@ -31,19 +127,104 @@ const getAvailableDscResources = () => 'json', ).pipe(Command.string); - yield* Effect.logDebug( - `DSC resources list output: ${dscrResourcesListOutput}`, - ); + // Parse NDJSON output + const rawResources = parseNdjson(dscrResourcesListOutput); + yield* Effect.log(`Found ${rawResources.length} resources in DSC output`); - return [] as Array; + // Decode each resource with the schema + const resources: Array = []; + for (const raw of rawResources) { + const decoded = S.decodeUnknownOption(DscResourceSchema)(raw); + if (decoded._tag === 'Some') { + resources.push(decoded.value); + } else { + // Log which resource failed to parse for debugging + const maybeType = + typeof raw === 'object' && raw !== null && 'type' in raw + ? (raw as { type: unknown }).type + : 'unknown'; + yield* Effect.logDebug(`Failed to decode resource: ${maybeType}`); + } + } + + yield* Effect.log(`Successfully decoded ${resources.length} resources`); + return resources; }); +/** + * Generate index file that re-exports all types + */ +const generateIndexFile = ( + resourceTypes: Array<{ type: string; filename: string; typeName: string }>, +) => { + const lines = [ + '// This file is auto-generated. Do not edit manually.', + '// Re-exports all DSC resource schema types', + '', + ]; + + for (const { filename, typeName } of resourceTypes) { + lines.push(`export * as ${typeName} from './${filename}';`); + } + + lines.push(''); + return lines.join('\n'); +}; + +/** + * Generate a types list file for all DSC resource configurations + */ +const generateDscConfigTypes = ( + resourceTypes: Array<{ type: string; filename: string; typeName: string }>, +) => { + const lines = [ + '// This file is auto-generated. Do not edit manually.', + "import * as S from 'effect/Schema';", + '', + ]; + + // Create a resource types literal + lines.push('/**'); + lines.push(' * All available DSC resource types on this system'); + lines.push(' */'); + lines.push('export const DscResourceTypes = S.Literal('); + for (const { type } of resourceTypes) { + lines.push(` "${type}",`); + } + lines.push(');'); + lines.push(''); + lines.push( + 'export type DscResourceType = S.Schema.Type;', + ); + lines.push(''); + + // Create a map of type to schema import + lines.push('/**'); + lines.push(' * Map of resource type to generated file'); + lines.push(' */'); + lines.push('export const ResourceTypeToFile = {'); + for (const { type, filename } of resourceTypes) { + lines.push(` "${type}": "${filename}.gen",`); + } + lines.push('} as const;'); + lines.push(''); + + return lines.join('\n'); +}; + const genDscResourcesTypes = Effect.gen(function* () { yield* Effect.log('Starting DSC resources types generation...'); - const availableResourceTypes = yield* getAvailableDscResources(); + const resources = yield* getAvailableDscResources(); + + // Filter to only resources that have schemas and are not adapters + // (adapters like PowerShell adapter don't have their own config schema) + const resourcesWithSchemas = resources.filter( + (r) => r.manifest.schema && r.kind !== 'adapter', + ); + yield* Effect.log( - `Found available resource types: ${availableResourceTypes.join(', ')}`, + `Found ${resourcesWithSchemas.length} resources with schemas (excluding adapters)`, ); const fs = yield* FileSystem.FileSystem; @@ -64,21 +245,92 @@ const genDscResourcesTypes = Effect.gen(function* () { yield* fs.makeDirectory(outputDir, { recursive: true }); - for (const schemaType of availableResourceTypes) { - yield* Effect.logDebug(`Processing: ${schemaType}`); + const generatedTypes: Array<{ + type: string; + filename: string; + typeName: string; + }> = []; + const errors: Array<{ type: string; error: string }> = []; - const jsonSchema = yield* getDscResourceJsonSchema(schemaType); - const effectSchema = yield* jsonSchemaToEffectSchema({ - jsonSchema, - name: schemaType, - }); + for (const resource of resourcesWithSchemas) { + yield* Effect.logDebug(`Processing: ${resource.type}`); - const outputPath = path.join(outputDir, `${schemaType}.gen.ts`); + const schemaResult = yield* Effect.either(getDscResourceSchema(resource)); + + if (schemaResult._tag === 'Left') { + errors.push({ + type: resource.type, + error: String(schemaResult.left), + }); + yield* Effect.logWarning( + `Failed to get schema for ${resource.type}: ${schemaResult.left}`, + ); + continue; + } + + const jsonSchema = schemaResult.right; + if (!jsonSchema) { + yield* Effect.logDebug(`No schema available for ${resource.type}`); + continue; + } + + const typeName = sanitizeTypeName(resource.type); + const filename = toSafeFilename(resource.type); + + const effectSchemaResult = yield* Effect.either( + jsonSchemaToEffectSchema({ + jsonSchema, + name: typeName, + }), + ); + + if (effectSchemaResult._tag === 'Left') { + errors.push({ + type: resource.type, + error: String(effectSchemaResult.left), + }); + yield* Effect.logWarning( + `Failed to convert schema for ${resource.type}: ${effectSchemaResult.left}`, + ); + continue; + } + + const effectSchema = effectSchemaResult.right; + const outputPath = path.join(outputDir, `${filename}.gen.ts`); yield* fs.writeFileString(outputPath, effectSchema); - yield* Effect.log(`Generated: ${schemaType}.gen.ts`); + generatedTypes.push({ + type: resource.type, + filename, + typeName, + }); + + yield* Effect.log(`Generated: ${filename}.gen.ts (${resource.type})`); } + // Generate index file + if (generatedTypes.length > 0) { + const indexContent = generateIndexFile(generatedTypes); + const indexPath = path.join(outputDir, 'index.ts'); + yield* fs.writeFileString(indexPath, indexContent); + yield* Effect.log('Generated: index.ts'); + + // Generate types list file + const typesListContent = generateDscConfigTypes(generatedTypes); + const typesListPath = path.join(outputDir, '_resource-types.gen.ts'); + yield* fs.writeFileString(typesListPath, typesListContent); + yield* Effect.log('Generated: _resource-types.gen.ts'); + } + + yield* Effect.log(''); + yield* Effect.log('=== Generation Summary ==='); + yield* Effect.log(`Successfully generated: ${generatedTypes.length} types`); + if (errors.length > 0) { + yield* Effect.log(`Failed: ${errors.length} types`); + for (const { type, error } of errors) { + yield* Effect.logDebug(` - ${type}: ${error}`); + } + } yield* Effect.log('DSC types generation complete!'); }); diff --git a/scripts/gen-dsc-types.ts b/scripts/gen-dsc-types.ts index cdbf181..54faf68 100644 --- a/scripts/gen-dsc-types.ts +++ b/scripts/gen-dsc-types.ts @@ -17,16 +17,11 @@ const getPossibleDscSchemaTypes = () => Effect.gen(function* () { yield* Effect.logDebug('Getting possible DSC schema types...'); - const brokenCommand = Command.make( - 'dsc', - 'schema', - '--type', - 'something-that-hopefully-never-exists', - ); + const dscSchemaHelp = Command.make('dsc', 'schema', '--help'); - const { stderr: brokenCommandOutput } = yield* runCommand(brokenCommand); + const { stdout: dscHelpOutput } = yield* runCommand(dscSchemaHelp); - const possibleTypes = brokenCommandOutput + const possibleTypes = dscHelpOutput .split('\n') .filter((line) => line.includes('possible values:')) .map((line) => { diff --git a/src/bin.ts b/src/bin.ts index 68b5bbc..26d898a 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -3,24 +3,24 @@ import { BunContext, BunRuntime } from '@effect/platform-bun'; import { Effect } from 'effect'; import pkg from '../package.json' with { type: 'json' }; -// import type { Configuration } from './dsc-schema-types/configuration.gen'; +import type { Configuration } from './dsc-schema-types/configuration.gen'; -// const machineConfig: typeof Configuration.Type = { -// $schema: 'https://aka.ms/dsc/schemas/v3/config/document.json', -// resources: [ -// { -// name: 'must be unique', -// type: 'Microsoft.Windows/Registry', -// properties: { -// keyPath: 'HKCU\\example\\key', -// valueName: 'Example', -// valueData: { -// String: 'Example Value', -// }, -// }, -// }, -// ], -// }; +const machineConfig: typeof Configuration.Type = { + $schema: 'https://aka.ms/dsc/schemas/v3/config/document.json', + resources: [ + { + name: 'must be unique', + type: 'Microsoft.Windows/Registry', + properties: { + keyPath: 'HKCU\\example\\key', + valueName: 'Example', + valueData: { + String: 'Example Value', + }, + }, + }, + ], +}; const diffCommand = Command.make('diff', {}, () => Effect.gen(function* () { diff --git a/src/dsc-schema-types/configuration-get-result.gen.ts b/src/dsc-schema-types/configuration-get-result.gen.ts index d5a5a49..375aac4 100644 --- a/src/dsc-schema-types/configuration-get-result.gen.ts +++ b/src/dsc-schema-types/configuration-get-result.gen.ts @@ -1,81 +1,86 @@ // This file is auto-generated. Do not edit manually. import * as S from 'effect/Schema'; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; export const ResourceGetResponse = S.Struct({ - actualState: S.Unknown, + "actualState": S.Unknown }); export type ResourceGetResponse = S.Schema.Type; -export const MessageLevel = S.Literal('error', 'warning', 'information'); +export const MessageLevel = S.Literal( + "error", + "warning", + "information" +); export type MessageLevel = S.Schema.Type; export const ResourceMessage = S.Struct({ - name: S.String, - type: S.String, - message: S.String, - level: MessageLevel, + "name": S.String, + "type": S.String, + "message": S.String, + "level": MessageLevel }); export type ResourceMessage = S.Schema.Type; export const ConfigurationGetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - results: S.Array( - S.suspend((): S.Schema => ResourceGetResult), - ), - messages: S.Array(ResourceMessage), - hadErrors: S.Boolean, + "metadata": S.optional(S.NullOr(Metadata)), + "results": S.Array(S.suspend((): S.Schema => ResourceGetResult)), + "messages": S.Array(ResourceMessage), + "hadErrors": S.Boolean }); -export type ConfigurationGetResult = S.Schema.Type< - typeof ConfigurationGetResult ->; +export type ConfigurationGetResult = S.Schema.Type; // Recursive type declarations -type ResourceGetResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: GetResult; -}; -type GetResult = ResourceGetResponse | ReadonlyArray; +interface ResourceGetResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": GetResult +} +type GetResult = ResourceGetResponse | ReadonlyArray // Recursive schema definitions export const ResourceGetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => GetResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => GetResult) }) as unknown as S.Schema; -export const GetResult = S.Union( - ResourceGetResponse, - S.Array(S.suspend((): S.Schema => ResourceGetResult)), -) as unknown as S.Schema; +export const GetResult = S.Union(ResourceGetResponse, S.Array(S.suspend((): S.Schema => ResourceGetResult))) as unknown as S.Schema; diff --git a/src/dsc-schema-types/configuration-set-result.gen.ts b/src/dsc-schema-types/configuration-set-result.gen.ts index f399a0b..f4fadca 100644 --- a/src/dsc-schema-types/configuration-set-result.gen.ts +++ b/src/dsc-schema-types/configuration-set-result.gen.ts @@ -1,83 +1,88 @@ // This file is auto-generated. Do not edit manually. import * as S from 'effect/Schema'; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; export const ResourceSetResponse = S.Struct({ - beforeState: S.Unknown, - afterState: S.Unknown, - changedProperties: S.optional(S.NullOr(S.Array(S.String))), + "beforeState": S.Unknown, + "afterState": S.Unknown, + "changedProperties": S.optional(S.NullOr(S.Array(S.String))) }); export type ResourceSetResponse = S.Schema.Type; -export const MessageLevel = S.Literal('error', 'warning', 'information'); +export const MessageLevel = S.Literal( + "error", + "warning", + "information" +); export type MessageLevel = S.Schema.Type; export const ResourceMessage = S.Struct({ - name: S.String, - type: S.String, - message: S.String, - level: MessageLevel, + "name": S.String, + "type": S.String, + "message": S.String, + "level": MessageLevel }); export type ResourceMessage = S.Schema.Type; export const ConfigurationSetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - results: S.Array( - S.suspend((): S.Schema => ResourceSetResult), - ), - messages: S.Array(ResourceMessage), - hadErrors: S.Boolean, + "metadata": S.optional(S.NullOr(Metadata)), + "results": S.Array(S.suspend((): S.Schema => ResourceSetResult)), + "messages": S.Array(ResourceMessage), + "hadErrors": S.Boolean }); -export type ConfigurationSetResult = S.Schema.Type< - typeof ConfigurationSetResult ->; +export type ConfigurationSetResult = S.Schema.Type; // Recursive type declarations -type ResourceSetResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: SetResult; -}; -type SetResult = ResourceSetResponse | ReadonlyArray; +interface ResourceSetResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": SetResult +} +type SetResult = ResourceSetResponse | ReadonlyArray // Recursive schema definitions export const ResourceSetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => SetResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => SetResult) }) as unknown as S.Schema; -export const SetResult = S.Union( - ResourceSetResponse, - S.Array(S.suspend((): S.Schema => ResourceSetResult)), -) as unknown as S.Schema; +export const SetResult = S.Union(ResourceSetResponse, S.Array(S.suspend((): S.Schema => ResourceSetResult))) as unknown as S.Schema; diff --git a/src/dsc-schema-types/configuration-test-result.gen.ts b/src/dsc-schema-types/configuration-test-result.gen.ts index 5dcc0c3..d2b6138 100644 --- a/src/dsc-schema-types/configuration-test-result.gen.ts +++ b/src/dsc-schema-types/configuration-test-result.gen.ts @@ -1,84 +1,89 @@ // This file is auto-generated. Do not edit manually. import * as S from 'effect/Schema'; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; export const ResourceTestResponse = S.Struct({ - desiredState: S.Unknown, - actualState: S.Unknown, - inDesiredState: S.Boolean, - differingProperties: S.Array(S.String), + "desiredState": S.Unknown, + "actualState": S.Unknown, + "inDesiredState": S.Boolean, + "differingProperties": S.Array(S.String) }); export type ResourceTestResponse = S.Schema.Type; -export const MessageLevel = S.Literal('error', 'warning', 'information'); +export const MessageLevel = S.Literal( + "error", + "warning", + "information" +); export type MessageLevel = S.Schema.Type; export const ResourceMessage = S.Struct({ - name: S.String, - type: S.String, - message: S.String, - level: MessageLevel, + "name": S.String, + "type": S.String, + "message": S.String, + "level": MessageLevel }); export type ResourceMessage = S.Schema.Type; export const ConfigurationTestResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - results: S.Array( - S.suspend((): S.Schema => ResourceTestResult), - ), - messages: S.Array(ResourceMessage), - hadErrors: S.Boolean, + "metadata": S.optional(S.NullOr(Metadata)), + "results": S.Array(S.suspend((): S.Schema => ResourceTestResult)), + "messages": S.Array(ResourceMessage), + "hadErrors": S.Boolean }); -export type ConfigurationTestResult = S.Schema.Type< - typeof ConfigurationTestResult ->; +export type ConfigurationTestResult = S.Schema.Type; // Recursive type declarations -type ResourceTestResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: TestResult; -}; -type TestResult = ResourceTestResponse | ReadonlyArray; +interface ResourceTestResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": TestResult +} +type TestResult = ResourceTestResponse | ReadonlyArray // Recursive schema definitions export const ResourceTestResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => TestResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => TestResult) }) as unknown as S.Schema; -export const TestResult = S.Union( - ResourceTestResponse, - S.Array(S.suspend((): S.Schema => ResourceTestResult)), -) as unknown as S.Schema; +export const TestResult = S.Union(ResourceTestResponse, S.Array(S.suspend((): S.Schema => ResourceTestResult))) as unknown as S.Schema; diff --git a/src/dsc-schema-types/configuration.gen.ts b/src/dsc-schema-types/configuration.gen.ts index d2d263f..04659f7 100644 --- a/src/dsc-schema-types/configuration.gen.ts +++ b/src/dsc-schema-types/configuration.gen.ts @@ -2,98 +2,81 @@ import * as S from 'effect/Schema'; export const DataType = S.Literal( - 'string', - 'secureString', - 'int', - 'bool', - 'object', - 'secureObject', - 'array', + "string", + "secureString", + "int", + "bool", + "object", + "secureObject", + "array" ); export type DataType = S.Schema.Type; export const Parameter = S.Struct({ - type: DataType, - defaultValue: S.optional(S.Unknown), - allowedValues: S.optional(S.NullOr(S.Array(S.Unknown))), - minValue: S.optional(S.NullOr(S.Number)), - maxValue: S.optional(S.NullOr(S.Number)), - minLength: S.optional(S.NullOr(S.Number)), - maxLength: S.optional(S.NullOr(S.Number)), - description: S.optional(S.NullOr(S.String)), - metadata: S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))), + "type": DataType, + "defaultValue": S.optional(S.Unknown), + "allowedValues": S.optional(S.NullOr(S.Array(S.Unknown))), + "minValue": S.optional(S.NullOr(S.Number)), + "maxValue": S.optional(S.NullOr(S.Number)), + "minLength": S.optional(S.NullOr(S.Number)), + "maxLength": S.optional(S.NullOr(S.Number)), + "description": S.optional(S.NullOr(S.String)), + "metadata": S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))) }); export type Parameter = S.Schema.Type; export const Resource = S.Struct({ - type: S.String, - name: S.String, - dependsOn: S.optional(S.NullOr(S.Array(S.String))), - properties: S.optional( - S.NullOr(S.Record({ key: S.String, value: S.Unknown })), - ), - metadata: S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))), + "type": S.String, + "name": S.String, + "dependsOn": S.optional(S.NullOr(S.Array(S.String))), + "properties": S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))), + "metadata": S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))) }); export type Resource = S.Schema.Type; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; export const Configuration = S.Struct({ - $schema: S.Literal( - 'https://aka.ms/dsc/schemas/v3/bundled/config/document.json', - 'https://aka.ms/dsc/schemas/v3.0/bundled/config/document.json', - 'https://aka.ms/dsc/schemas/v3.0.0/bundled/config/document.json', - 'https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json', - 'https://aka.ms/dsc/schemas/v3.0/bundled/config/document.vscode.json', - 'https://aka.ms/dsc/schemas/v3.0.0/bundled/config/document.vscode.json', - 'https://aka.ms/dsc/schemas/v3/config/document.json', - 'https://aka.ms/dsc/schemas/v3.0/config/document.json', - 'https://aka.ms/dsc/schemas/v3.0.0/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/config/document.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/config/document.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/config/document.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/config/document.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/config/document.json', - ), - contentVersion: S.optional(S.NullOr(S.String)), - parameters: S.optional( - S.NullOr(S.Record({ key: S.String, value: Parameter })), - ), - variables: S.optional( - S.NullOr(S.Record({ key: S.String, value: S.Unknown })), - ), - resources: S.Array(Resource), - metadata: S.optional(S.NullOr(Metadata)), + "$schema": S.Literal("https://aka.ms/dsc/schemas/v3/bundled/config/document.json", "https://aka.ms/dsc/schemas/v3.0/bundled/config/document.json", "https://aka.ms/dsc/schemas/v3.0.0/bundled/config/document.json", "https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json", "https://aka.ms/dsc/schemas/v3.0/bundled/config/document.vscode.json", "https://aka.ms/dsc/schemas/v3.0.0/bundled/config/document.vscode.json", "https://aka.ms/dsc/schemas/v3/config/document.json", "https://aka.ms/dsc/schemas/v3.0/config/document.json", "https://aka.ms/dsc/schemas/v3.0.0/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/config/document.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/config/document.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/config/document.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/config/document.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/config/document.json"), + "contentVersion": S.optional(S.NullOr(S.String)), + "parameters": S.optional(S.NullOr(S.Record({ key: S.String, value: Parameter }))), + "variables": S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))), + "resources": S.Array(Resource), + "metadata": S.optional(S.NullOr(Metadata)) }); export type Configuration = S.Schema.Type; diff --git a/src/dsc-schema-types/dsc-resource.gen.ts b/src/dsc-schema-types/dsc-resource.gen.ts index b70a335..372b402 100644 --- a/src/dsc-schema-types/dsc-resource.gen.ts +++ b/src/dsc-schema-types/dsc-resource.gen.ts @@ -2,41 +2,36 @@ import * as S from 'effect/Schema'; export const Kind = S.Literal( - 'adapter', - 'exporter', - 'group', - 'importer', - 'resource', + "adapter", + "exporter", + "group", + "importer", + "resource" ); export type Kind = S.Schema.Type; -export const Capability = S.Union( - S.Literal('get'), - S.Literal('set'), - S.Literal('setHandlesExist'), - S.Literal('whatIf'), - S.Literal('test'), - S.Literal('delete'), - S.Literal('export'), - S.Literal('resolve'), -); +export const Capability = S.Union(S.Literal("get"), S.Literal("set"), S.Literal("setHandlesExist"), S.Literal("whatIf"), S.Literal("test"), S.Literal("delete"), S.Literal("export"), S.Literal("resolve")); export type Capability = S.Schema.Type; export const ImplementedAs = S.NullOr(S.String); export type ImplementedAs = S.Schema.Type; export const DscResource = S.Struct({ - type: S.String, - kind: S.Struct({}), - version: S.String, - capabilities: S.Array(Capability), - path: S.String, - description: S.optional(S.NullOr(S.String)), - directory: S.String, - implementedAs: S.Struct({}), - author: S.optional(S.NullOr(S.String)), - properties: S.Array(S.String), - requireAdapter: S.optional(S.NullOr(S.String)), - manifest: S.optional(S.Unknown), + "type": S.String, + "kind": S.Struct({ + +}), + "version": S.String, + "capabilities": S.Array(Capability), + "path": S.String, + "description": S.optional(S.NullOr(S.String)), + "directory": S.String, + "implementedAs": S.Struct({ + +}), + "author": S.optional(S.NullOr(S.String)), + "properties": S.Array(S.String), + "requireAdapter": S.optional(S.NullOr(S.String)), + "manifest": S.optional(S.Unknown) }); export type DscResource = S.Schema.Type; diff --git a/src/dsc-schema-types/get-result.gen.ts b/src/dsc-schema-types/get-result.gen.ts index fdf3caa..59069b5 100644 --- a/src/dsc-schema-types/get-result.gen.ts +++ b/src/dsc-schema-types/get-result.gen.ts @@ -2,57 +2,62 @@ import * as S from 'effect/Schema'; export const ResourceGetResponse = S.Struct({ - actualState: S.Unknown, + "actualState": S.Unknown }); export type ResourceGetResponse = S.Schema.Type; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; // Recursive type declarations -type ResourceGetResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: GetResult; -}; -type GetResult = ResourceGetResponse | ReadonlyArray; +interface ResourceGetResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": GetResult +} +type GetResult = ResourceGetResponse | ReadonlyArray // Recursive schema definitions export const ResourceGetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => GetResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => GetResult) }) as unknown as S.Schema; -export const GetResult = S.Union( - ResourceGetResponse, - S.Array(S.suspend((): S.Schema => ResourceGetResult)), -) as unknown as S.Schema; +export const GetResult = S.Union(ResourceGetResponse, S.Array(S.suspend((): S.Schema => ResourceGetResult))) as unknown as S.Schema; diff --git a/src/dsc-schema-types/include.gen.ts b/src/dsc-schema-types/include.gen.ts index c4480b4..9d60218 100644 --- a/src/dsc-schema-types/include.gen.ts +++ b/src/dsc-schema-types/include.gen.ts @@ -1,12 +1,9 @@ // This file is auto-generated. Do not edit manually. import * as S from 'effect/Schema'; -export const Include = S.Union( - S.Struct({ - configurationFile: S.String, - }), - S.Struct({ - configurationContent: S.String, - }), -); +export const Include = S.Union(S.Struct({ + "configurationFile": S.String +}), S.Struct({ + "configurationContent": S.String +})); export type Include = S.Schema.Type; diff --git a/src/dsc-schema-types/resolve-result.gen.ts b/src/dsc-schema-types/resolve-result.gen.ts index 1913702..bd35c41 100644 --- a/src/dsc-schema-types/resolve-result.gen.ts +++ b/src/dsc-schema-types/resolve-result.gen.ts @@ -2,9 +2,7 @@ import * as S from 'effect/Schema'; export const ResolveResult = S.Struct({ - configuration: S.Unknown, - parameters: S.optional( - S.NullOr(S.Record({ key: S.String, value: S.Unknown })), - ), + "configuration": S.Unknown, + "parameters": S.optional(S.NullOr(S.Record({ key: S.String, value: S.Unknown }))) }); export type ResolveResult = S.Schema.Type; diff --git a/src/dsc-schema-types/resource-manifest.gen.ts b/src/dsc-schema-types/resource-manifest.gen.ts index a1d7f0a..aa090c3 100644 --- a/src/dsc-schema-types/resource-manifest.gen.ts +++ b/src/dsc-schema-types/resource-manifest.gen.ts @@ -2,152 +2,128 @@ import * as S from 'effect/Schema'; export const Kind = S.Literal( - 'adapter', - 'exporter', - 'group', - 'importer', - 'resource', + "adapter", + "exporter", + "group", + "importer", + "resource" ); export type Kind = S.Schema.Type; -export const ArgKind = S.Union( - S.String, - S.Struct({ - jsonInputArg: S.String, - mandatory: S.optional(S.NullOr(S.Boolean)), - }), -); +export const ArgKind = S.Union(S.String, S.Struct({ + "jsonInputArg": S.String, + "mandatory": S.optional(S.NullOr(S.Boolean)) +})); export type ArgKind = S.Schema.Type; -export const InputKind = S.Union(S.Literal('env'), S.Literal('stdin')); +export const InputKind = S.Union(S.Literal("env"), S.Literal("stdin")); export type InputKind = S.Schema.Type; export const GetMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)) }); export type GetMethod = S.Schema.Type; -export const ReturnKind = S.Union( - S.Literal('state'), - S.Literal('stateAndDiff'), -); +export const ReturnKind = S.Union(S.Literal("state"), S.Literal("stateAndDiff")); export type ReturnKind = S.Schema.Type; export const SetMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), - implementsPretest: S.optional(S.NullOr(S.Boolean)), - handlesExist: S.optional(S.NullOr(S.Boolean)), - return: S.optional(S.NullOr(ReturnKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)), + "implementsPretest": S.optional(S.NullOr(S.Boolean)), + "handlesExist": S.optional(S.NullOr(S.Boolean)), + "return": S.optional(S.NullOr(ReturnKind)) }); export type SetMethod = S.Schema.Type; export const TestMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), - return: S.optional(S.NullOr(ReturnKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)), + "return": S.optional(S.NullOr(ReturnKind)) }); export type TestMethod = S.Schema.Type; export const DeleteMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)) }); export type DeleteMethod = S.Schema.Type; export const ExportMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)) }); export type ExportMethod = S.Schema.Type; export const ResolveMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)) }); export type ResolveMethod = S.Schema.Type; export const ValidateMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(ArgKind))), - input: S.optional(S.NullOr(InputKind)), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(ArgKind))), + "input": S.optional(S.NullOr(InputKind)) }); export type ValidateMethod = S.Schema.Type; export const ListMethod = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(S.String))), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(S.String))) }); export type ListMethod = S.Schema.Type; -export const ConfigKind = S.Union(S.Literal('full'), S.Literal('sequence')); +export const ConfigKind = S.Union(S.Literal("full"), S.Literal("sequence")); export type ConfigKind = S.Schema.Type; export const Adapter = S.Struct({ - list: S.Struct({}), - config: S.Struct({}), + "list": S.Struct({ + +}), + "config": S.Struct({ + +}) }); export type Adapter = S.Schema.Type; export const SchemaCommand = S.Struct({ - executable: S.String, - args: S.optional(S.NullOr(S.Array(S.String))), + "executable": S.String, + "args": S.optional(S.NullOr(S.Array(S.String))) }); export type SchemaCommand = S.Schema.Type; -export const SchemaKind = S.Union( - S.Struct({ - command: SchemaCommand, - }), - S.Struct({ - embedded: S.Unknown, - }), -); +export const SchemaKind = S.Union(S.Struct({ + "command": SchemaCommand +}), S.Struct({ + "embedded": S.Unknown +})); export type SchemaKind = S.Schema.Type; export const ResourceManifest = S.Struct({ - $schema: S.Literal( - 'https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json', - 'https://aka.ms/dsc/schemas/v3.0/bundled/resource/manifest.json', - 'https://aka.ms/dsc/schemas/v3.0.0/bundled/resource/manifest.json', - 'https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.vscode.json', - 'https://aka.ms/dsc/schemas/v3.0/bundled/resource/manifest.vscode.json', - 'https://aka.ms/dsc/schemas/v3.0.0/bundled/resource/manifest.vscode.json', - 'https://aka.ms/dsc/schemas/v3/resource/manifest.json', - 'https://aka.ms/dsc/schemas/v3.0/resource/manifest.json', - 'https://aka.ms/dsc/schemas/v3.0.0/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/resource/manifest.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/resource/manifest.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/resource/manifest.vscode.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/resource/manifest.json', - 'https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/resource/manifest.json', - ), - type: S.String, - kind: S.optional(S.NullOr(Kind)), - version: S.String, - description: S.optional(S.NullOr(S.String)), - tags: S.optional(S.NullOr(S.Array(S.String))), - get: S.optional(S.NullOr(GetMethod)), - set: S.optional(S.NullOr(SetMethod)), - whatIf: S.optional(S.NullOr(SetMethod)), - test: S.optional(S.NullOr(TestMethod)), - delete: S.optional(S.NullOr(DeleteMethod)), - export: S.optional(S.NullOr(ExportMethod)), - resolve: S.optional(S.NullOr(ResolveMethod)), - validate: S.optional(S.NullOr(ValidateMethod)), - adapter: S.optional(S.NullOr(Adapter)), - exitCodes: S.optional(S.NullOr(S.Record({ key: S.String, value: S.String }))), - schema: S.optional(S.NullOr(SchemaKind)), + "$schema": S.Literal("https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json", "https://aka.ms/dsc/schemas/v3.0/bundled/resource/manifest.json", "https://aka.ms/dsc/schemas/v3.0.0/bundled/resource/manifest.json", "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.vscode.json", "https://aka.ms/dsc/schemas/v3.0/bundled/resource/manifest.vscode.json", "https://aka.ms/dsc/schemas/v3.0.0/bundled/resource/manifest.vscode.json", "https://aka.ms/dsc/schemas/v3/resource/manifest.json", "https://aka.ms/dsc/schemas/v3.0/resource/manifest.json", "https://aka.ms/dsc/schemas/v3.0.0/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/bundled/resource/manifest.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/bundled/resource/manifest.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/bundled/resource/manifest.vscode.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0/resource/manifest.json", "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.0.0/resource/manifest.json"), + "type": S.String, + "kind": S.optional(S.NullOr(Kind)), + "version": S.String, + "description": S.optional(S.NullOr(S.String)), + "tags": S.optional(S.NullOr(S.Array(S.String))), + "get": S.optional(S.NullOr(GetMethod)), + "set": S.optional(S.NullOr(SetMethod)), + "whatIf": S.optional(S.NullOr(SetMethod)), + "test": S.optional(S.NullOr(TestMethod)), + "delete": S.optional(S.NullOr(DeleteMethod)), + "export": S.optional(S.NullOr(ExportMethod)), + "resolve": S.optional(S.NullOr(ResolveMethod)), + "validate": S.optional(S.NullOr(ValidateMethod)), + "adapter": S.optional(S.NullOr(Adapter)), + "exitCodes": S.optional(S.NullOr(S.Record({ key: S.String, value: S.String }))), + "schema": S.optional(S.NullOr(SchemaKind)) }); export type ResourceManifest = S.Schema.Type; diff --git a/src/dsc-schema-types/set-result.gen.ts b/src/dsc-schema-types/set-result.gen.ts index c9c7741..1727df1 100644 --- a/src/dsc-schema-types/set-result.gen.ts +++ b/src/dsc-schema-types/set-result.gen.ts @@ -2,59 +2,64 @@ import * as S from 'effect/Schema'; export const ResourceSetResponse = S.Struct({ - beforeState: S.Unknown, - afterState: S.Unknown, - changedProperties: S.optional(S.NullOr(S.Array(S.String))), + "beforeState": S.Unknown, + "afterState": S.Unknown, + "changedProperties": S.optional(S.NullOr(S.Array(S.String))) }); export type ResourceSetResponse = S.Schema.Type; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; // Recursive type declarations -type ResourceSetResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: SetResult; -}; -type SetResult = ResourceSetResponse | ReadonlyArray; +interface ResourceSetResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": SetResult +} +type SetResult = ResourceSetResponse | ReadonlyArray // Recursive schema definitions export const ResourceSetResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => SetResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => SetResult) }) as unknown as S.Schema; -export const SetResult = S.Union( - ResourceSetResponse, - S.Array(S.suspend((): S.Schema => ResourceSetResult)), -) as unknown as S.Schema; +export const SetResult = S.Union(ResourceSetResponse, S.Array(S.suspend((): S.Schema => ResourceSetResult))) as unknown as S.Schema; diff --git a/src/dsc-schema-types/test-result.gen.ts b/src/dsc-schema-types/test-result.gen.ts index 9260d67..65d708b 100644 --- a/src/dsc-schema-types/test-result.gen.ts +++ b/src/dsc-schema-types/test-result.gen.ts @@ -2,60 +2,65 @@ import * as S from 'effect/Schema'; export const ResourceTestResponse = S.Struct({ - desiredState: S.Unknown, - actualState: S.Unknown, - inDesiredState: S.Boolean, - differingProperties: S.Array(S.String), + "desiredState": S.Unknown, + "actualState": S.Unknown, + "inDesiredState": S.Boolean, + "differingProperties": S.Array(S.String) }); export type ResourceTestResponse = S.Schema.Type; -export const Operation = S.Literal('get', 'set', 'test', 'export'); +export const Operation = S.Literal( + "get", + "set", + "test", + "export" +); export type Operation = S.Schema.Type; -export const ExecutionKind = S.Literal('actual', 'whatIf'); +export const ExecutionKind = S.Literal( + "actual", + "whatIf" +); export type ExecutionKind = S.Schema.Type; export const SecurityContextKind = S.Literal( - 'current', - 'elevated', - 'restricted', + "current", + "elevated", + "restricted" ); export type SecurityContextKind = S.Schema.Type; export const MicrosoftDscMetadata = S.Struct({ - version: S.optional(S.NullOr(S.String)), - operation: S.optional(S.NullOr(Operation)), - executionType: S.optional(S.NullOr(ExecutionKind)), - startDatetime: S.optional(S.NullOr(S.String)), - endDatetime: S.optional(S.NullOr(S.String)), - duration: S.optional(S.NullOr(S.String)), - securityContext: S.optional(S.NullOr(SecurityContextKind)), + "version": S.optional(S.NullOr(S.String)), + "operation": S.optional(S.NullOr(Operation)), + "executionType": S.optional(S.NullOr(ExecutionKind)), + "startDatetime": S.optional(S.NullOr(S.String)), + "endDatetime": S.optional(S.NullOr(S.String)), + "duration": S.optional(S.NullOr(S.String)), + "securityContext": S.optional(S.NullOr(SecurityContextKind)) }); export type MicrosoftDscMetadata = S.Schema.Type; export const Metadata = S.Struct({ - 'Microsoft.DSC': S.optional(S.NullOr(MicrosoftDscMetadata)), + "Microsoft.DSC": S.optional(S.NullOr(MicrosoftDscMetadata)) }); export type Metadata = S.Schema.Type; // Recursive type declarations -type ResourceTestResult = { - readonly metadata?: Metadata | null; - readonly name: string; - readonly type: string; - readonly result: TestResult; -}; -type TestResult = ResourceTestResponse | ReadonlyArray; +interface ResourceTestResult { + readonly "metadata"?: Metadata | null; + readonly "name": string; + readonly "type": string; + readonly "result": TestResult +} +type TestResult = ResourceTestResponse | ReadonlyArray // Recursive schema definitions export const ResourceTestResult = S.Struct({ - metadata: S.optional(S.NullOr(Metadata)), - name: S.String, - type: S.String, - result: S.suspend((): S.Schema => TestResult), + "metadata": S.optional(S.NullOr(Metadata)), + "name": S.String, + "type": S.String, + "result": S.suspend((): S.Schema => TestResult) }) as unknown as S.Schema; -export const TestResult = S.Union( - ResourceTestResponse, - S.Array(S.suspend((): S.Schema => ResourceTestResult)), -) as unknown as S.Schema; +export const TestResult = S.Union(ResourceTestResponse, S.Array(S.suspend((): S.Schema => ResourceTestResult))) as unknown as S.Schema;