@actions/workflow-parser 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/model/convert.d.ts +31 -0
- package/dist/model/convert.d.ts.map +1 -0
- package/dist/model/convert.js +105 -0
- package/dist/model/convert.js.map +1 -0
- package/dist/model/converter/concurrency.d.ts +5 -0
- package/dist/model/converter/concurrency.d.ts.map +1 -0
- package/dist/model/converter/concurrency.js +30 -0
- package/dist/model/converter/concurrency.js.map +1 -0
- package/dist/model/converter/container.d.ts +6 -0
- package/dist/model/converter/container.d.ts.map +1 -0
- package/dist/model/converter/container.js +97 -0
- package/dist/model/converter/container.js.map +1 -0
- package/dist/model/converter/cron-constants.d.ts +44 -0
- package/dist/model/converter/cron-constants.d.ts.map +1 -0
- package/dist/model/converter/cron-constants.js +30 -0
- package/dist/model/converter/cron-constants.js.map +1 -0
- package/dist/model/converter/cron.d.ts +3 -0
- package/dist/model/converter/cron.d.ts.map +1 -0
- package/dist/model/converter/cron.js +92 -0
- package/dist/model/converter/cron.js.map +1 -0
- package/dist/model/converter/events.d.ts +5 -0
- package/dist/model/converter/events.d.ts.map +1 -0
- package/dist/model/converter/events.js +123 -0
- package/dist/model/converter/events.js.map +1 -0
- package/dist/model/converter/handle-errors.d.ts +4 -0
- package/dist/model/converter/handle-errors.d.ts.map +1 -0
- package/dist/model/converter/handle-errors.js +18 -0
- package/dist/model/converter/handle-errors.js.map +1 -0
- package/dist/model/converter/id-builder.d.ts +23 -0
- package/dist/model/converter/id-builder.d.ts.map +1 -0
- package/dist/model/converter/id-builder.js +113 -0
- package/dist/model/converter/id-builder.js.map +1 -0
- package/dist/model/converter/job/environment.d.ts +5 -0
- package/dist/model/converter/job/environment.d.ts.map +1 -0
- package/dist/model/converter/job/environment.js +28 -0
- package/dist/model/converter/job/environment.js.map +1 -0
- package/dist/model/converter/job/inputs.d.ts +8 -0
- package/dist/model/converter/job/inputs.d.ts.map +1 -0
- package/dist/model/converter/job/inputs.js +38 -0
- package/dist/model/converter/job/inputs.js.map +1 -0
- package/dist/model/converter/job/runs-on.d.ts +9 -0
- package/dist/model/converter/job/runs-on.d.ts.map +1 -0
- package/dist/model/converter/job/runs-on.js +78 -0
- package/dist/model/converter/job/runs-on.js.map +1 -0
- package/dist/model/converter/job/secrets.d.ts +4 -0
- package/dist/model/converter/job/secrets.d.ts.map +1 -0
- package/dist/model/converter/job/secrets.js +32 -0
- package/dist/model/converter/job/secrets.js.map +1 -0
- package/dist/model/converter/job.d.ts +5 -0
- package/dist/model/converter/job.d.ts.map +1 -0
- package/dist/model/converter/job.js +144 -0
- package/dist/model/converter/job.js.map +1 -0
- package/dist/model/converter/jobs.d.ts +5 -0
- package/dist/model/converter/jobs.d.ts.map +1 -0
- package/dist/model/converter/jobs.js +74 -0
- package/dist/model/converter/jobs.js.map +1 -0
- package/dist/model/converter/referencedWorkflow.d.ts +5 -0
- package/dist/model/converter/referencedWorkflow.d.ts.map +1 -0
- package/dist/model/converter/referencedWorkflow.js +85 -0
- package/dist/model/converter/referencedWorkflow.js.map +1 -0
- package/dist/model/converter/steps.d.ts +5 -0
- package/dist/model/converter/steps.d.ts.map +1 -0
- package/dist/model/converter/steps.js +113 -0
- package/dist/model/converter/steps.js.map +1 -0
- package/dist/model/converter/string-list.d.ts +3 -0
- package/dist/model/converter/string-list.d.ts.map +1 -0
- package/dist/model/converter/string-list.js +8 -0
- package/dist/model/converter/string-list.js.map +1 -0
- package/dist/model/converter/workflow-call.d.ts +5 -0
- package/dist/model/converter/workflow-call.d.ts.map +1 -0
- package/dist/model/converter/workflow-call.js +45 -0
- package/dist/model/converter/workflow-call.js.map +1 -0
- package/dist/model/converter/workflow-dispatch.d.ts +9 -0
- package/dist/model/converter/workflow-dispatch.d.ts.map +1 -0
- package/dist/model/converter/workflow-dispatch.js +82 -0
- package/dist/model/converter/workflow-dispatch.js.map +1 -0
- package/dist/model/type-guards.d.ts +6 -0
- package/dist/model/type-guards.d.ts.map +1 -0
- package/dist/model/type-guards.js +13 -0
- package/dist/model/type-guards.js.map +1 -0
- package/dist/model/workflow-template.d.ts +157 -0
- package/dist/model/workflow-template.d.ts.map +1 -0
- package/dist/model/workflow-template.js +8 -0
- package/dist/model/workflow-template.js.map +1 -0
- package/dist/templates/allowed-context.d.ts +6 -0
- package/dist/templates/allowed-context.d.ts.map +1 -0
- package/dist/templates/allowed-context.js +30 -0
- package/dist/templates/allowed-context.js.map +1 -0
- package/dist/templates/json-object-reader.d.ts +20 -0
- package/dist/templates/json-object-reader.d.ts.map +1 -0
- package/dist/templates/json-object-reader.js +135 -0
- package/dist/templates/json-object-reader.js.map +1 -0
- package/dist/templates/object-reader.d.ts +15 -0
- package/dist/templates/object-reader.d.ts.map +1 -0
- package/dist/templates/object-reader.js +2 -0
- package/dist/templates/object-reader.js.map +1 -0
- package/dist/templates/parse-event.d.ts +16 -0
- package/dist/templates/parse-event.d.ts.map +1 -0
- package/dist/templates/parse-event.js +17 -0
- package/dist/templates/parse-event.js.map +1 -0
- package/dist/templates/schema/boolean-definition.d.ts +10 -0
- package/dist/templates/schema/boolean-definition.d.ts.map +1 -0
- package/dist/templates/schema/boolean-definition.js +41 -0
- package/dist/templates/schema/boolean-definition.js.map +1 -0
- package/dist/templates/schema/definition-info.d.ts +16 -0
- package/dist/templates/schema/definition-info.d.ts.map +1 -0
- package/dist/templates/schema/definition-info.js +40 -0
- package/dist/templates/schema/definition-info.js.map +1 -0
- package/dist/templates/schema/definition-type.d.ts +11 -0
- package/dist/templates/schema/definition-type.d.ts.map +1 -0
- package/dist/templates/schema/definition-type.js +12 -0
- package/dist/templates/schema/definition-type.js.map +1 -0
- package/dist/templates/schema/definition.d.ts +24 -0
- package/dist/templates/schema/definition.d.ts.map +1 -0
- package/dist/templates/schema/definition.js +62 -0
- package/dist/templates/schema/definition.js.map +1 -0
- package/dist/templates/schema/index.d.ts +2 -0
- package/dist/templates/schema/index.d.ts.map +1 -0
- package/dist/templates/schema/index.js +2 -0
- package/dist/templates/schema/index.js.map +1 -0
- package/dist/templates/schema/mapping-definition.d.ts +16 -0
- package/dist/templates/schema/mapping-definition.d.ts.map +1 -0
- package/dist/templates/schema/mapping-definition.js +81 -0
- package/dist/templates/schema/mapping-definition.js.map +1 -0
- package/dist/templates/schema/null-definition.d.ts +10 -0
- package/dist/templates/schema/null-definition.d.ts.map +1 -0
- package/dist/templates/schema/null-definition.js +41 -0
- package/dist/templates/schema/null-definition.js.map +1 -0
- package/dist/templates/schema/number-definition.d.ts +10 -0
- package/dist/templates/schema/number-definition.d.ts.map +1 -0
- package/dist/templates/schema/number-definition.js +41 -0
- package/dist/templates/schema/number-definition.js.map +1 -0
- package/dist/templates/schema/one-of-definition.d.ts +15 -0
- package/dist/templates/schema/one-of-definition.d.ts.map +1 -0
- package/dist/templates/schema/one-of-definition.js +154 -0
- package/dist/templates/schema/one-of-definition.js.map +1 -0
- package/dist/templates/schema/property-definition.d.ts +8 -0
- package/dist/templates/schema/property-definition.d.ts.map +1 -0
- package/dist/templates/schema/property-definition.js +31 -0
- package/dist/templates/schema/property-definition.js.map +1 -0
- package/dist/templates/schema/scalar-definition.d.ts +7 -0
- package/dist/templates/schema/scalar-definition.d.ts.map +1 -0
- package/dist/templates/schema/scalar-definition.js +7 -0
- package/dist/templates/schema/scalar-definition.js.map +1 -0
- package/dist/templates/schema/sequence-definition.d.ts +11 -0
- package/dist/templates/schema/sequence-definition.d.ts.map +1 -0
- package/dist/templates/schema/sequence-definition.js +47 -0
- package/dist/templates/schema/sequence-definition.js.map +1 -0
- package/dist/templates/schema/string-definition.d.ts +14 -0
- package/dist/templates/schema/string-definition.d.ts.map +1 -0
- package/dist/templates/schema/string-definition.js +79 -0
- package/dist/templates/schema/string-definition.js.map +1 -0
- package/dist/templates/schema/template-schema.d.ts +47 -0
- package/dist/templates/schema/template-schema.d.ts.map +1 -0
- package/dist/templates/schema/template-schema.js +377 -0
- package/dist/templates/schema/template-schema.js.map +1 -0
- package/dist/templates/template-constants.d.ts +49 -0
- package/dist/templates/template-constants.d.ts.map +1 -0
- package/dist/templates/template-constants.js +49 -0
- package/dist/templates/template-constants.js.map +1 -0
- package/dist/templates/template-context.d.ts +66 -0
- package/dist/templates/template-context.d.ts.map +1 -0
- package/dist/templates/template-context.js +118 -0
- package/dist/templates/template-context.js.map +1 -0
- package/dist/templates/template-reader.d.ts +9 -0
- package/dist/templates/template-reader.d.ts.map +1 -0
- package/dist/templates/template-reader.js +595 -0
- package/dist/templates/template-reader.js.map +1 -0
- package/dist/templates/template-validation-error.d.ts +14 -0
- package/dist/templates/template-validation-error.d.ts.map +1 -0
- package/dist/templates/template-validation-error.js +21 -0
- package/dist/templates/template-validation-error.js.map +1 -0
- package/dist/templates/tokens/basic-expression-token.d.ts +27 -0
- package/dist/templates/tokens/basic-expression-token.d.ts.map +1 -0
- package/dist/templates/tokens/basic-expression-token.js +38 -0
- package/dist/templates/tokens/basic-expression-token.js.map +1 -0
- package/dist/templates/tokens/boolean-token.d.ts +12 -0
- package/dist/templates/tokens/boolean-token.d.ts.map +1 -0
- package/dist/templates/tokens/boolean-token.js +23 -0
- package/dist/templates/tokens/boolean-token.js.map +1 -0
- package/dist/templates/tokens/expression-token.d.ts +11 -0
- package/dist/templates/tokens/expression-token.d.ts.map +1 -0
- package/dist/templates/tokens/expression-token.js +24 -0
- package/dist/templates/tokens/expression-token.js.map +1 -0
- package/dist/templates/tokens/index.d.ts +14 -0
- package/dist/templates/tokens/index.d.ts.map +1 -0
- package/dist/templates/tokens/index.js +14 -0
- package/dist/templates/tokens/index.js.map +1 -0
- package/dist/templates/tokens/insert-expression-token.d.ts +12 -0
- package/dist/templates/tokens/insert-expression-token.d.ts.map +1 -0
- package/dist/templates/tokens/insert-expression-token.js +26 -0
- package/dist/templates/tokens/insert-expression-token.js.map +1 -0
- package/dist/templates/tokens/key-value-pair.d.ts +8 -0
- package/dist/templates/tokens/key-value-pair.d.ts.map +1 -0
- package/dist/templates/tokens/key-value-pair.js +7 -0
- package/dist/templates/tokens/key-value-pair.js.map +1 -0
- package/dist/templates/tokens/literal-token.d.ts +14 -0
- package/dist/templates/tokens/literal-token.d.ts.map +1 -0
- package/dist/templates/tokens/literal-token.js +22 -0
- package/dist/templates/tokens/literal-token.js.map +1 -0
- package/dist/templates/tokens/mapping-token.d.ts +20 -0
- package/dist/templates/tokens/mapping-token.d.ts.map +1 -0
- package/dist/templates/tokens/mapping-token.js +58 -0
- package/dist/templates/tokens/mapping-token.js.map +1 -0
- package/dist/templates/tokens/null-token.d.ts +10 -0
- package/dist/templates/tokens/null-token.d.ts.map +1 -0
- package/dist/templates/tokens/null-token.js +19 -0
- package/dist/templates/tokens/null-token.js.map +1 -0
- package/dist/templates/tokens/number-token.d.ts +12 -0
- package/dist/templates/tokens/number-token.d.ts.map +1 -0
- package/dist/templates/tokens/number-token.js +23 -0
- package/dist/templates/tokens/number-token.js.map +1 -0
- package/dist/templates/tokens/scalar-token.d.ts +14 -0
- package/dist/templates/tokens/scalar-token.d.ts.map +1 -0
- package/dist/templates/tokens/scalar-token.js +22 -0
- package/dist/templates/tokens/scalar-token.js.map +1 -0
- package/dist/templates/tokens/sequence-token.d.ts +18 -0
- package/dist/templates/tokens/sequence-token.d.ts.map +1 -0
- package/dist/templates/tokens/sequence-token.js +47 -0
- package/dist/templates/tokens/sequence-token.js.map +1 -0
- package/dist/templates/tokens/serialization.d.ts +21 -0
- package/dist/templates/tokens/serialization.d.ts.map +1 -0
- package/dist/templates/tokens/serialization.js +2 -0
- package/dist/templates/tokens/serialization.js.map +1 -0
- package/dist/templates/tokens/string-token.d.ts +12 -0
- package/dist/templates/tokens/string-token.d.ts.map +1 -0
- package/dist/templates/tokens/string-token.js +21 -0
- package/dist/templates/tokens/string-token.js.map +1 -0
- package/dist/templates/tokens/template-token.d.ts +70 -0
- package/dist/templates/tokens/template-token.d.ts.map +1 -0
- package/dist/templates/tokens/template-token.js +138 -0
- package/dist/templates/tokens/template-token.js.map +1 -0
- package/dist/templates/tokens/token-range.d.ts +12 -0
- package/dist/templates/tokens/token-range.d.ts.map +1 -0
- package/dist/templates/tokens/token-range.js +2 -0
- package/dist/templates/tokens/token-range.js.map +1 -0
- package/dist/templates/tokens/traversal-state.d.ts +12 -0
- package/dist/templates/tokens/traversal-state.d.ts.map +1 -0
- package/dist/templates/tokens/traversal-state.js +54 -0
- package/dist/templates/tokens/traversal-state.js.map +1 -0
- package/dist/templates/tokens/type-guards.d.ts +18 -0
- package/dist/templates/tokens/type-guards.d.ts.map +1 -0
- package/dist/templates/tokens/type-guards.js +28 -0
- package/dist/templates/tokens/type-guards.js.map +1 -0
- package/dist/templates/tokens/types.d.ts +12 -0
- package/dist/templates/tokens/types.d.ts.map +1 -0
- package/dist/templates/tokens/types.js +37 -0
- package/dist/templates/tokens/types.js.map +1 -0
- package/dist/templates/trace-writer.d.ts +11 -0
- package/dist/templates/trace-writer.d.ts.map +1 -0
- package/dist/templates/trace-writer.js +12 -0
- package/dist/templates/trace-writer.js.map +1 -0
- package/dist/test-utils/null-trace.d.ts +3 -0
- package/dist/test-utils/null-trace.d.ts.map +1 -0
- package/dist/test-utils/null-trace.js +3 -0
- package/dist/test-utils/null-trace.js.map +1 -0
- package/dist/workflow-v1.0.json +2511 -0
- package/dist/workflows/file-provider.d.ts +6 -0
- package/dist/workflows/file-provider.d.ts.map +1 -0
- package/dist/workflows/file-provider.js +2 -0
- package/dist/workflows/file-provider.js.map +1 -0
- package/dist/workflows/file-reference.d.ts +13 -0
- package/dist/workflows/file-reference.d.ts.map +1 -0
- package/dist/workflows/file-reference.js +25 -0
- package/dist/workflows/file-reference.js.map +1 -0
- package/dist/workflows/file.d.ts +5 -0
- package/dist/workflows/file.d.ts.map +1 -0
- package/dist/workflows/file.js +2 -0
- package/dist/workflows/file.js.map +1 -0
- package/dist/workflows/workflow-constants.d.ts +2 -0
- package/dist/workflows/workflow-constants.d.ts.map +1 -0
- package/dist/workflows/workflow-constants.js +2 -0
- package/dist/workflows/workflow-constants.js.map +1 -0
- package/dist/workflows/workflow-parser.d.ts +11 -0
- package/dist/workflows/workflow-parser.d.ts.map +1 -0
- package/dist/workflows/workflow-parser.js +28 -0
- package/dist/workflows/workflow-parser.js.map +1 -0
- package/dist/workflows/workflow-schema.d.ts +3 -0
- package/dist/workflows/workflow-schema.d.ts.map +1 -0
- package/dist/workflows/workflow-schema.js +12 -0
- package/dist/workflows/workflow-schema.js.map +1 -0
- package/dist/workflows/yaml-object-reader.d.ts +26 -0
- package/dist/workflows/yaml-object-reader.d.ts.map +1 -0
- package/dist/workflows/yaml-object-reader.js +178 -0
- package/dist/workflows/yaml-object-reader.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-definition.js","sourceRoot":"","sources":["../../../src/templates/schema/boolean-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,iBAAkB,SAAQ,gBAAgB;IACrD,YAAmB,GAAW,EAAE,UAAyB;QACvD,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACvB,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,cAAc,IAAI,UAAU,EAAE;gBACvC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC;gBAC3E,QAAQ,aAAa,CAAC,KAAK,EAAE;oBAC3B,KAAK,OAAO,CAAC,CAAC;wBACZ,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,UAAU,IAAI,OAAO,EAAE,CAAC,CAAC;wBAC/E,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE;4BACjC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;4BAChF,QAAQ,UAAU,CAAC,KAAK,EAAE;gCACxB;oCACE,SAAS;oCACT,UAAU,CAAC,qBAAqB,CAAC,GAAG,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;oCACjE,MAAM;6BACT;yBACF;wBACD,MAAM;qBACP;oBACD;wBACE,aAAa,CAAC,qBAAqB,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,SAAS;iBACtE;aACF;SACF;IACH,CAAC;IAED,IAAoB,cAAc;QAChC,OAAO,cAAc,CAAC,OAAO,CAAC;IAChC,CAAC;IAEe,OAAO,CAAC,OAAqB;QAC3C,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,CAAC,OAAO,CAAC;IACzD,CAAC;IAEe,QAAQ;QACtB,QAAQ;IACV,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateSchema } from ".";
|
|
2
|
+
import { Definition } from "./definition";
|
|
3
|
+
import { DefinitionType } from "./definition-type";
|
|
4
|
+
import { ScalarDefinition } from "./scalar-definition";
|
|
5
|
+
export declare class DefinitionInfo {
|
|
6
|
+
private readonly _schema;
|
|
7
|
+
readonly isDefinitionInfo = true;
|
|
8
|
+
readonly definition: Definition;
|
|
9
|
+
readonly allowedContext: string[];
|
|
10
|
+
constructor(schema: TemplateSchema, name: string);
|
|
11
|
+
constructor(parent: DefinitionInfo, name: string);
|
|
12
|
+
constructor(parent: DefinitionInfo, definition: Definition);
|
|
13
|
+
getScalarDefinitions(): ScalarDefinition[];
|
|
14
|
+
getDefinitionsOfType(type: DefinitionType): Definition[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=definition-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition-info.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/definition-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,GAAG,CAAC;AACjC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAErD,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,SAAgB,gBAAgB,QAAQ;IACxC,SAAgB,UAAU,EAAE,UAAU,CAAC;IACvC,SAAgB,cAAc,EAAE,MAAM,EAAE,CAAC;gBAEtB,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM;gBACpC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM;gBACpC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU;IAoC1D,oBAAoB,IAAI,gBAAgB,EAAE;IAI1C,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,EAAE;CAGhE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class DefinitionInfo {
|
|
2
|
+
constructor(schemaOrParent, nameOrDefinition) {
|
|
3
|
+
this.isDefinitionInfo = true;
|
|
4
|
+
const parent = schemaOrParent?.isDefinitionInfo === true
|
|
5
|
+
? schemaOrParent
|
|
6
|
+
: undefined;
|
|
7
|
+
this._schema = parent === undefined ? schemaOrParent : parent._schema;
|
|
8
|
+
// Lookup the definition if a key was passed in
|
|
9
|
+
this.definition =
|
|
10
|
+
typeof nameOrDefinition === "string" ? this._schema.getDefinition(nameOrDefinition) : nameOrDefinition;
|
|
11
|
+
// Record allowed context
|
|
12
|
+
if (this.definition.readerContext.length > 0) {
|
|
13
|
+
this.allowedContext = [];
|
|
14
|
+
// Copy parent allowed context
|
|
15
|
+
const upperSeen = {};
|
|
16
|
+
for (const context of parent?.allowedContext ?? []) {
|
|
17
|
+
this.allowedContext.push(context);
|
|
18
|
+
upperSeen[context.toUpperCase()] = true;
|
|
19
|
+
}
|
|
20
|
+
// Append context if unseen
|
|
21
|
+
for (const context of this.definition.readerContext) {
|
|
22
|
+
const upper = context.toUpperCase();
|
|
23
|
+
if (!upperSeen[upper]) {
|
|
24
|
+
this.allowedContext.push(context);
|
|
25
|
+
upperSeen[upper] = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.allowedContext = parent?.allowedContext ?? [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
getScalarDefinitions() {
|
|
34
|
+
return this._schema.getScalarDefinitions(this.definition);
|
|
35
|
+
}
|
|
36
|
+
getDefinitionsOfType(type) {
|
|
37
|
+
return this._schema.getDefinitionsOfType(this.definition, type);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=definition-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition-info.js","sourceRoot":"","sources":["../../../src/templates/schema/definition-info.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,cAAc;IASzB,YAAmB,cAA+C,EAAE,gBAAqC;QAPzF,qBAAgB,GAAG,IAAI,CAAC;QAQtC,MAAM,MAAM,GACT,cAA6C,EAAE,gBAAgB,KAAK,IAAI;YACvE,CAAC,CAAE,cAAiC;YACpC,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAE,cAAiC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QAE1F,+CAA+C;QAC/C,IAAI,CAAC,UAAU;YACb,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAg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,OAAO,IAAA;IACP,MAAM,IAAA;IACN,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,KAAK,IAAA;IACL,aAAa,IAAA;CACd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var DefinitionType;
|
|
2
|
+
(function (DefinitionType) {
|
|
3
|
+
DefinitionType[DefinitionType["Null"] = 0] = "Null";
|
|
4
|
+
DefinitionType[DefinitionType["Boolean"] = 1] = "Boolean";
|
|
5
|
+
DefinitionType[DefinitionType["Number"] = 2] = "Number";
|
|
6
|
+
DefinitionType[DefinitionType["String"] = 3] = "String";
|
|
7
|
+
DefinitionType[DefinitionType["Sequence"] = 4] = "Sequence";
|
|
8
|
+
DefinitionType[DefinitionType["Mapping"] = 5] = "Mapping";
|
|
9
|
+
DefinitionType[DefinitionType["OneOf"] = 6] = "OneOf";
|
|
10
|
+
DefinitionType[DefinitionType["AllowedValues"] = 7] = "AllowedValues";
|
|
11
|
+
})(DefinitionType || (DefinitionType = {}));
|
|
12
|
+
//# sourceMappingURL=definition-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition-type.js","sourceRoot":"","sources":["../../../src/templates/schema/definition-type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB,mDAAI,CAAA;IACJ,yDAAO,CAAA;IACP,uDAAM,CAAA;IACN,uDAAM,CAAA;IACN,2DAAQ,CAAA;IACR,yDAAO,CAAA;IACP,qDAAK,CAAA;IACL,qEAAa,CAAA;AACf,CAAC,EATW,cAAc,KAAd,cAAc,QASzB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MappingToken } from "../tokens";
|
|
2
|
+
import { DefinitionType } from "./definition-type";
|
|
3
|
+
import { TemplateSchema } from "./template-schema";
|
|
4
|
+
/**
|
|
5
|
+
* Defines the allowable schema for a user defined type
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Definition {
|
|
8
|
+
/**
|
|
9
|
+
* Used by the template reader to determine allowed expression values and functions.
|
|
10
|
+
* Also used by the template reader to validate function min/max parameters.
|
|
11
|
+
*/
|
|
12
|
+
readonly readerContext: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Used by the template evaluator to determine allowed expression values and functions.
|
|
15
|
+
* The min/max parameter info is omitted.
|
|
16
|
+
*/
|
|
17
|
+
readonly evaluatorContext: string[];
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly description: string | undefined;
|
|
20
|
+
constructor(key: string, definition?: MappingToken);
|
|
21
|
+
abstract get definitionType(): DefinitionType;
|
|
22
|
+
abstract validate(schema: TemplateSchema, name: string): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD;;GAEG;AACH,8BAAsB,UAAU;IAC9B;;;OAGG;IACH,SAAgB,aAAa,EAAE,MAAM,EAAE,CAAM;IAE7C;;;OAGG;IACH,SAAgB,gBAAgB,EAAE,MAAM,EAAE,CAAM;IAGhD,SAAgB,GAAG,EAAE,MAAM,CAAC;IAE5B,SAAgB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE7B,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,YAAY;IAgDzD,aAAoB,cAAc,IAAI,cAAc,CAAC;aAErC,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CACrE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CONTEXT, DEFINITION, DESCRIPTION } from "../template-constants";
|
|
2
|
+
/**
|
|
3
|
+
* Defines the allowable schema for a user defined type
|
|
4
|
+
*/
|
|
5
|
+
export class Definition {
|
|
6
|
+
constructor(key, definition) {
|
|
7
|
+
/**
|
|
8
|
+
* Used by the template reader to determine allowed expression values and functions.
|
|
9
|
+
* Also used by the template reader to validate function min/max parameters.
|
|
10
|
+
*/
|
|
11
|
+
this.readerContext = [];
|
|
12
|
+
/**
|
|
13
|
+
* Used by the template evaluator to determine allowed expression values and functions.
|
|
14
|
+
* The min/max parameter info is omitted.
|
|
15
|
+
*/
|
|
16
|
+
this.evaluatorContext = [];
|
|
17
|
+
this.key = key;
|
|
18
|
+
if (definition) {
|
|
19
|
+
for (let i = 0; i < definition.count;) {
|
|
20
|
+
const definitionKey = definition.get(i).key.assertString(`${DEFINITION} key`);
|
|
21
|
+
switch (definitionKey.value) {
|
|
22
|
+
case CONTEXT: {
|
|
23
|
+
const context = definition.get(i).value.assertSequence(`${DEFINITION} ${CONTEXT}`);
|
|
24
|
+
definition.remove(i);
|
|
25
|
+
const seenReaderContext = {};
|
|
26
|
+
const seenEvaluatorContext = {};
|
|
27
|
+
for (const item of context) {
|
|
28
|
+
const itemStr = item.assertString(`${CONTEXT} item`).value;
|
|
29
|
+
const upperItemStr = itemStr.toUpperCase();
|
|
30
|
+
if (seenReaderContext[upperItemStr]) {
|
|
31
|
+
throw new Error(`Duplicate context item '${itemStr}'`);
|
|
32
|
+
}
|
|
33
|
+
seenReaderContext[upperItemStr] = true;
|
|
34
|
+
this.readerContext.push(itemStr);
|
|
35
|
+
// Remove min/max parameter info
|
|
36
|
+
const paramIndex = itemStr.indexOf("(");
|
|
37
|
+
const modifiedItemStr = paramIndex > 0 ? itemStr.substr(0, paramIndex + 1) + ")" : itemStr;
|
|
38
|
+
const upperModifiedItemStr = modifiedItemStr.toUpperCase();
|
|
39
|
+
if (seenEvaluatorContext[upperModifiedItemStr]) {
|
|
40
|
+
throw new Error(`Duplicate context item '${modifiedItemStr}'`);
|
|
41
|
+
}
|
|
42
|
+
seenEvaluatorContext[upperModifiedItemStr] = true;
|
|
43
|
+
this.evaluatorContext.push(modifiedItemStr);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case DESCRIPTION: {
|
|
48
|
+
const value = definition.get(i).value;
|
|
49
|
+
this.description = value.assertString(DESCRIPTION).value;
|
|
50
|
+
definition.remove(i);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
default: {
|
|
54
|
+
i++;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/templates/schema/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAKvE;;GAEG;AACH,MAAM,OAAgB,UAAU;IAkB9B,YAAmB,GAAW,EAAE,UAAyB;QAjBzD;;;WAGG;QACa,kBAAa,GAAa,EAAE,CAAC;QAE7C;;;WAGG;QACa,qBAAgB,GAAa,EAAE,CAAC;QAQ9C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,UAAU,EAAE;YACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,KAAK,GAAI;gBACtC,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC;gBAC9E,QAAQ,aAAa,CAAC,KAAK,EAAE;oBAC3B,KAAK,OAAO,CAAC,CAAC;wBACZ,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,UAAU,IAA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CAAC,CAAC,CAAC,KAAK,CAAC;wBACtC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC;wBACzD,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;wBACrB,MAAM;qBACP;oBACD,OAAO,CAAC,CAAC;wBACP,CAAC,EAAE,CAAC;wBACJ,MAAM;qBACP;iBACF;aACF;SACF;IACH,CAAC;CAKF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateSchema } from "./template-schema";
|
|
2
|
+
import { MappingToken } from "../tokens";
|
|
3
|
+
import { Definition } from "./definition";
|
|
4
|
+
import { DefinitionType } from "./definition-type";
|
|
5
|
+
import { PropertyDefinition } from "./property-definition";
|
|
6
|
+
export declare class MappingDefinition extends Definition {
|
|
7
|
+
readonly properties: {
|
|
8
|
+
[key: string]: PropertyDefinition;
|
|
9
|
+
};
|
|
10
|
+
looseKeyType: string;
|
|
11
|
+
looseValueType: string;
|
|
12
|
+
constructor(key: string, definition?: MappingToken);
|
|
13
|
+
get definitionType(): DefinitionType;
|
|
14
|
+
validate(schema: TemplateSchema, name: string): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mapping-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-definition.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/mapping-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,iBAAkB,SAAQ,UAAU;IAC/C,SAAgB,UAAU,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAC,CAAM;IAC9D,YAAY,SAAM;IAClB,cAAc,SAAM;gBAER,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,YAAY;IA4CzD,IAAoB,cAAc,IAAI,cAAc,CAEnD;IAEe,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CA6BrE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DEFINITION, MAPPING, PROPERTIES, LOOSE_KEY_TYPE, LOOSE_VALUE_TYPE } from "../template-constants";
|
|
2
|
+
import { Definition } from "./definition";
|
|
3
|
+
import { DefinitionType } from "./definition-type";
|
|
4
|
+
import { PropertyDefinition } from "./property-definition";
|
|
5
|
+
export class MappingDefinition extends Definition {
|
|
6
|
+
constructor(key, definition) {
|
|
7
|
+
super(key, definition);
|
|
8
|
+
this.properties = {};
|
|
9
|
+
this.looseKeyType = "";
|
|
10
|
+
this.looseValueType = "";
|
|
11
|
+
if (definition) {
|
|
12
|
+
for (const definitionPair of definition) {
|
|
13
|
+
const definitionKey = definitionPair.key.assertString(`${DEFINITION} key`);
|
|
14
|
+
switch (definitionKey.value) {
|
|
15
|
+
case MAPPING: {
|
|
16
|
+
const mapping = definitionPair.value.assertMapping(`${DEFINITION} ${MAPPING}`);
|
|
17
|
+
for (const mappingPair of mapping) {
|
|
18
|
+
const mappingKey = mappingPair.key.assertString(`${DEFINITION} ${MAPPING} key`);
|
|
19
|
+
switch (mappingKey.value) {
|
|
20
|
+
case PROPERTIES: {
|
|
21
|
+
const properties = mappingPair.value.assertMapping(`${DEFINITION} ${MAPPING} ${PROPERTIES}`);
|
|
22
|
+
for (const propertiesPair of properties) {
|
|
23
|
+
const propertyName = propertiesPair.key.assertString(`${DEFINITION} ${MAPPING} ${PROPERTIES} key`);
|
|
24
|
+
this.properties[propertyName.value] = new PropertyDefinition(propertiesPair.value);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case LOOSE_KEY_TYPE: {
|
|
29
|
+
const looseKeyType = mappingPair.value.assertString(`${DEFINITION} ${MAPPING} ${LOOSE_KEY_TYPE}`);
|
|
30
|
+
this.looseKeyType = looseKeyType.value;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case LOOSE_VALUE_TYPE: {
|
|
34
|
+
const looseValueType = mappingPair.value.assertString(`${DEFINITION} ${MAPPING} ${LOOSE_VALUE_TYPE}`);
|
|
35
|
+
this.looseValueType = looseValueType.value;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
39
|
+
// throws
|
|
40
|
+
mappingKey.assertUnexpectedValue(`${DEFINITION} ${MAPPING} key`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
definitionKey.assertUnexpectedValue(`${DEFINITION} key`); // throws
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
get definitionType() {
|
|
53
|
+
return DefinitionType.Mapping;
|
|
54
|
+
}
|
|
55
|
+
validate(schema, name) {
|
|
56
|
+
// Lookup loose key type
|
|
57
|
+
if (this.looseKeyType) {
|
|
58
|
+
schema.getDefinition(this.looseKeyType);
|
|
59
|
+
// Lookup loose value type
|
|
60
|
+
if (this.looseValueType) {
|
|
61
|
+
schema.getDefinition(this.looseValueType);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new Error(`Property '${LOOSE_KEY_TYPE}' is defined but '${LOOSE_VALUE_TYPE}' is not defined on '${name}'`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Otherwise validate loose value type not be defined
|
|
68
|
+
else if (this.looseValueType) {
|
|
69
|
+
throw new Error(`Property '${LOOSE_VALUE_TYPE}' is defined but '${LOOSE_KEY_TYPE}' is not defined on '${name}'`);
|
|
70
|
+
}
|
|
71
|
+
// Lookup each property
|
|
72
|
+
for (const propertyName of Object.keys(this.properties)) {
|
|
73
|
+
const propertyDef = this.properties[propertyName];
|
|
74
|
+
if (!propertyDef.type) {
|
|
75
|
+
throw new Error(`Type not specified for the property '${propertyName}' on '${name}'`);
|
|
76
|
+
}
|
|
77
|
+
schema.getDefinition(propertyDef.type);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=mapping-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping-definition.js","sourceRoot":"","sources":["../../../src/templates/schema/mapping-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAExG,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAK/C,YAAmB,GAAW,EAAE,UAAyB;QACvD,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QALT,eAAU,GAAwC,EAAE,CAAC;QAC9D,iBAAY,GAAG,EAAE,CAAC;QAClB,mBAAc,GAAG,EAAE,CAAC;QAIzB,IAAI,UAAU,EAAE;YACd,KAAK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AS,IAAI,GAAG,CAAC,CAAC;aACvF;YAED,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MappingToken, LiteralToken } from "../tokens";
|
|
2
|
+
import { DefinitionType } from "./definition-type";
|
|
3
|
+
import { ScalarDefinition } from "./scalar-definition";
|
|
4
|
+
export declare class NullDefinition extends ScalarDefinition {
|
|
5
|
+
constructor(key: string, definition?: MappingToken);
|
|
6
|
+
get definitionType(): DefinitionType;
|
|
7
|
+
isMatch(literal: LiteralToken): boolean;
|
|
8
|
+
validate(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=null-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null-definition.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/null-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,WAAW,CAAC;AACrD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,cAAe,SAAQ,gBAAgB;gBAC/B,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,YAAY;IA0BzD,IAAoB,cAAc,IAAI,cAAc,CAEnD;IAEe,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAIvC,QAAQ,IAAI,IAAI;CAGjC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DEFINITION, NULL } from "../template-constants";
|
|
2
|
+
import { DefinitionType } from "./definition-type";
|
|
3
|
+
import { ScalarDefinition } from "./scalar-definition";
|
|
4
|
+
import { TokenType } from "../tokens/types";
|
|
5
|
+
export class NullDefinition extends ScalarDefinition {
|
|
6
|
+
constructor(key, definition) {
|
|
7
|
+
super(key, definition);
|
|
8
|
+
if (definition) {
|
|
9
|
+
for (const definitionPair of definition) {
|
|
10
|
+
const definitionKey = definitionPair.key.assertString(`${DEFINITION} key`);
|
|
11
|
+
switch (definitionKey.value) {
|
|
12
|
+
case NULL: {
|
|
13
|
+
const mapping = definitionPair.value.assertMapping(`${DEFINITION} ${NULL}`);
|
|
14
|
+
for (const mappingPair of mapping) {
|
|
15
|
+
const mappingKey = mappingPair.key.assertString(`${DEFINITION} ${NULL} key`);
|
|
16
|
+
switch (mappingKey.value) {
|
|
17
|
+
default:
|
|
18
|
+
// throws
|
|
19
|
+
mappingKey.assertUnexpectedValue(`${DEFINITION} ${NULL} key`);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
default:
|
|
26
|
+
definitionKey.assertUnexpectedValue(`${DEFINITION} key`); // throws
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
get definitionType() {
|
|
32
|
+
return DefinitionType.Null;
|
|
33
|
+
}
|
|
34
|
+
isMatch(literal) {
|
|
35
|
+
return literal.templateTokenType === TokenType.Null;
|
|
36
|
+
}
|
|
37
|
+
validate() {
|
|
38
|
+
// no-op
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=null-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null-definition.js","sourceRoot":"","sources":["../../../src/templates/schema/null-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAClD,YAAmB,GAAW,EAAE,UAAyB;QACvD,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACvB,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,cAAc,IAAI,UAAU,EAAE;gBACvC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC;gBAC3E,QAAQ,aAAa,CAAC,KAAK,EAAE;oBAC3B,KAAK,IAAI,CAAC,CAAC;wBACT,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,UAAU,IAAI,IAAI,EAAE,CAAC,CAAC;wBAC5E,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE;4BACjC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,IAAI,IAAI,MAAM,CAAC,CAAC;4BAC7E,QAAQ,UAAU,CAAC,KAAK,EAAE;gCACxB;oCACE,SAAS;oCACT,UAAU,CAAC,qBAAqB,CAAC,GAAG,UAAU,IAAI,IAAI,MAAM,CAAC,CAAC;oCAC9D,MAAM;6BACT;yBACF;wBACD,MAAM;qBACP;oBACD;wBACE,aAAa,CAAC,qBAAqB,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,SAAS;iBACtE;aACF;SACF;IACH,CAAC;IAED,IAAoB,cAAc;QAChC,OAAO,cAAc,CAAC,IAAI,CAAC;IAC7B,CAAC;IAEe,OAAO,CAAC,OAAqB;QAC3C,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,CAAC,IAAI,CAAC;IACtD,CAAC;IAEe,QAAQ;QACtB,QAAQ;IACV,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MappingToken, LiteralToken } from "../tokens";
|
|
2
|
+
import { DefinitionType } from "./definition-type";
|
|
3
|
+
import { ScalarDefinition } from "./scalar-definition";
|
|
4
|
+
export declare class NumberDefinition extends ScalarDefinition {
|
|
5
|
+
constructor(key: string, definition?: MappingToken);
|
|
6
|
+
get definitionType(): DefinitionType;
|
|
7
|
+
isMatch(literal: LiteralToken): boolean;
|
|
8
|
+
validate(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=number-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-definition.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/number-definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,WAAW,CAAC;AACrD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACjC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,YAAY;IA0BzD,IAAoB,cAAc,IAAI,cAAc,CAEnD;IAEe,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAIvC,QAAQ,IAAI,IAAI;CAGjC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DEFINITION, NUMBER } from "../template-constants";
|
|
2
|
+
import { DefinitionType } from "./definition-type";
|
|
3
|
+
import { ScalarDefinition } from "./scalar-definition";
|
|
4
|
+
import { TokenType } from "../tokens/types";
|
|
5
|
+
export class NumberDefinition extends ScalarDefinition {
|
|
6
|
+
constructor(key, definition) {
|
|
7
|
+
super(key, definition);
|
|
8
|
+
if (definition) {
|
|
9
|
+
for (const definitionPair of definition) {
|
|
10
|
+
const definitionKey = definitionPair.key.assertString(`${DEFINITION} key`);
|
|
11
|
+
switch (definitionKey.value) {
|
|
12
|
+
case NUMBER: {
|
|
13
|
+
const mapping = definitionPair.value.assertMapping(`${DEFINITION} ${NUMBER}`);
|
|
14
|
+
for (const mappingPair of mapping) {
|
|
15
|
+
const mappingKey = mappingPair.key.assertString(`${DEFINITION} ${NUMBER} key`);
|
|
16
|
+
switch (mappingKey.value) {
|
|
17
|
+
default:
|
|
18
|
+
// throws
|
|
19
|
+
mappingKey.assertUnexpectedValue(`${DEFINITION} ${NUMBER} key`);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
default:
|
|
26
|
+
definitionKey.assertUnexpectedValue(`${DEFINITION} key`); // throws
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
get definitionType() {
|
|
32
|
+
return DefinitionType.Number;
|
|
33
|
+
}
|
|
34
|
+
isMatch(literal) {
|
|
35
|
+
return literal.templateTokenType === TokenType.Number;
|
|
36
|
+
}
|
|
37
|
+
validate() {
|
|
38
|
+
// no-op
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=number-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-definition.js","sourceRoot":"","sources":["../../../src/templates/schema/number-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IACpD,YAAmB,GAAW,EAAE,UAAyB;QACvD,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACvB,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,cAAc,IAAI,UAAU,EAAE;gBACvC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC;gBAC3E,QAAQ,aAAa,CAAC,KAAK,EAAE;oBAC3B,KAAK,MAAM,CAAC,CAAC;wBACX,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC,CAAC;wBAC9E,KAAK,MAAM,WAAW,IAAI,OAAO,EAAE;4BACjC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,UAAU,IAAI,MAAM,MAAM,CAAC,CAAC;4BAC/E,QAAQ,UAAU,CAAC,KAAK,EAAE;gCACxB;oCACE,SAAS;oCACT,UAAU,CAAC,qBAAqB,CAAC,GAAG,UAAU,IAAI,MAAM,MAAM,CAAC,CAAC;oCAChE,MAAM;6BACT;yBACF;wBACD,MAAM;qBACP;oBACD;wBACE,aAAa,CAAC,qBAAqB,CAAC,GAAG,UAAU,MAAM,CAAC,CAAC,CAAC,SAAS;iBACtE;aACF;SACF;IACH,CAAC;IAED,IAAoB,cAAc;QAChC,OAAO,cAAc,CAAC,MAAM,CAAC;IAC/B,CAAC;IAEe,OAAO,CAAC,OAAqB;QAC3C,OAAO,OAAO,CAAC,iBAAiB,KAAK,SAAS,CAAC,MAAM,CAAC;IACxD,CAAC;IAEe,QAAQ;QACtB,QAAQ;IACV,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TemplateSchema } from "./template-schema";
|
|
2
|
+
import { MappingToken } from "../tokens";
|
|
3
|
+
import { Definition } from "./definition";
|
|
4
|
+
import { DefinitionType } from "./definition-type";
|
|
5
|
+
/**
|
|
6
|
+
* Must resolve to exactly one of the referenced definitions
|
|
7
|
+
*/
|
|
8
|
+
export declare class OneOfDefinition extends Definition {
|
|
9
|
+
readonly oneOf: string[];
|
|
10
|
+
readonly oneOfPrefix: string[];
|
|
11
|
+
constructor(key: string, definition?: MappingToken);
|
|
12
|
+
get definitionType(): DefinitionType;
|
|
13
|
+
validate(schema: TemplateSchema, name: string): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=one-of-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-of-definition.d.ts","sourceRoot":"","sources":["../../../src/templates/schema/one-of-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAajD,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAQjD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,SAAgB,KAAK,EAAE,MAAM,EAAE,CAAM;IACrC,SAAgB,WAAW,EAAE,MAAM,EAAE,CAAM;gBAExB,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,YAAY;IA+BzD,IAAoB,cAAc,IAAI,cAAc,CAEnD;IAEe,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CA8HrE"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { DEFINITION, ONE_OF, SEQUENCE, NULL, BOOLEAN, NUMBER, SCALAR, CONSTANT, LOOSE_KEY_TYPE, ALLOWED_VALUES } from "../template-constants";
|
|
2
|
+
import { Definition } from "./definition";
|
|
3
|
+
import { DefinitionType } from "./definition-type";
|
|
4
|
+
/**
|
|
5
|
+
* Must resolve to exactly one of the referenced definitions
|
|
6
|
+
*/
|
|
7
|
+
export class OneOfDefinition extends Definition {
|
|
8
|
+
constructor(key, definition) {
|
|
9
|
+
super(key, definition);
|
|
10
|
+
this.oneOf = [];
|
|
11
|
+
this.oneOfPrefix = [];
|
|
12
|
+
if (definition) {
|
|
13
|
+
for (const definitionPair of definition) {
|
|
14
|
+
const definitionKey = definitionPair.key.assertString(`${DEFINITION} key`);
|
|
15
|
+
switch (definitionKey.value) {
|
|
16
|
+
case ONE_OF: {
|
|
17
|
+
const oneOf = definitionPair.value.assertSequence(`${DEFINITION} ${ONE_OF}`);
|
|
18
|
+
for (const item of oneOf) {
|
|
19
|
+
const oneOfItem = item.assertString(`${DEFINITION} ${ONE_OF} item`);
|
|
20
|
+
this.oneOf.push(oneOfItem.value);
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case ALLOWED_VALUES: {
|
|
25
|
+
const oneOf = definitionPair.value.assertSequence(`${DEFINITION} ${ALLOWED_VALUES}`);
|
|
26
|
+
for (const item of oneOf) {
|
|
27
|
+
const oneOfItem = item.assertString(`${DEFINITION} ${ONE_OF} item`);
|
|
28
|
+
this.oneOf.push(this.key + "-" + oneOfItem.value);
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
// throws
|
|
34
|
+
definitionKey.assertUnexpectedValue(`${DEFINITION} key`);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
get definitionType() {
|
|
41
|
+
return DefinitionType.OneOf;
|
|
42
|
+
}
|
|
43
|
+
validate(schema, name) {
|
|
44
|
+
if (this.oneOf.length === 0) {
|
|
45
|
+
throw new Error(`'${name}' does not contain any references`);
|
|
46
|
+
}
|
|
47
|
+
let foundLooseKeyType = false;
|
|
48
|
+
const mappingDefinitions = [];
|
|
49
|
+
let allowedValuesDefinition;
|
|
50
|
+
let sequenceDefinition;
|
|
51
|
+
let nullDefinition;
|
|
52
|
+
let booleanDefinition;
|
|
53
|
+
let numberDefinition;
|
|
54
|
+
const stringDefinitions = [];
|
|
55
|
+
const seenNestedTypes = {};
|
|
56
|
+
for (const nestedType of this.oneOf) {
|
|
57
|
+
if (seenNestedTypes[nestedType]) {
|
|
58
|
+
throw new Error(`'${name}' contains duplicate nested type '${nestedType}'`);
|
|
59
|
+
}
|
|
60
|
+
seenNestedTypes[nestedType] = true;
|
|
61
|
+
const nestedDefinition = schema.getDefinition(nestedType);
|
|
62
|
+
if (nestedDefinition.readerContext.length > 0) {
|
|
63
|
+
throw new Error(`'${name}' is a one-of definition and references another definition that defines context. This is currently not supported.`);
|
|
64
|
+
}
|
|
65
|
+
switch (nestedDefinition.definitionType) {
|
|
66
|
+
case DefinitionType.Mapping: {
|
|
67
|
+
const mappingDefinition = nestedDefinition;
|
|
68
|
+
mappingDefinitions.push(mappingDefinition);
|
|
69
|
+
if (mappingDefinition.looseKeyType) {
|
|
70
|
+
foundLooseKeyType = true;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case DefinitionType.Sequence: {
|
|
75
|
+
// Multiple sequence definitions not allowed
|
|
76
|
+
if (sequenceDefinition) {
|
|
77
|
+
throw new Error(`'${name}' refers to more than one definition of type '${SEQUENCE}'`);
|
|
78
|
+
}
|
|
79
|
+
sequenceDefinition = nestedDefinition;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case DefinitionType.Null: {
|
|
83
|
+
// Multiple null definitions not allowed
|
|
84
|
+
if (nullDefinition) {
|
|
85
|
+
throw new Error(`'${name}' refers to more than one definition of type '${NULL}'`);
|
|
86
|
+
}
|
|
87
|
+
nullDefinition = nestedDefinition;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case DefinitionType.Boolean: {
|
|
91
|
+
// Multiple boolean definitions not allowed
|
|
92
|
+
if (booleanDefinition) {
|
|
93
|
+
throw new Error(`'${name}' refers to more than one definition of type '${BOOLEAN}'`);
|
|
94
|
+
}
|
|
95
|
+
booleanDefinition = nestedDefinition;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case DefinitionType.Number: {
|
|
99
|
+
// Multiple number definitions not allowed
|
|
100
|
+
if (numberDefinition) {
|
|
101
|
+
throw new Error(`'${name}' refers to more than one definition of type '${NUMBER}'`);
|
|
102
|
+
}
|
|
103
|
+
numberDefinition = nestedDefinition;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case DefinitionType.String: {
|
|
107
|
+
const stringDefinition = nestedDefinition;
|
|
108
|
+
// Multiple string definitions
|
|
109
|
+
if (stringDefinitions.length > 0 && (!stringDefinitions[0].constant || !stringDefinition.constant)) {
|
|
110
|
+
throw new Error(`'${name}' refers to more than one '${SCALAR}', but some do not set '${CONSTANT}'`);
|
|
111
|
+
}
|
|
112
|
+
stringDefinitions.push(stringDefinition);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case DefinitionType.OneOf: {
|
|
116
|
+
// Multiple allowed-values definitions not allowed
|
|
117
|
+
if (allowedValuesDefinition) {
|
|
118
|
+
throw new Error(`'${name}' contains multiple allowed-values definitions`);
|
|
119
|
+
}
|
|
120
|
+
allowedValuesDefinition = nestedDefinition;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`'${name}' refers to a definition with type '${nestedDefinition.definitionType}'`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (mappingDefinitions.length > 1) {
|
|
128
|
+
if (foundLooseKeyType) {
|
|
129
|
+
throw new Error(`'${name}' refers to two mappings and at least one sets '${LOOSE_KEY_TYPE}'. This is not currently supported.`);
|
|
130
|
+
}
|
|
131
|
+
const seenProperties = {};
|
|
132
|
+
for (const mappingDefinition of mappingDefinitions) {
|
|
133
|
+
for (const propertyName of Object.keys(mappingDefinition.properties)) {
|
|
134
|
+
const newPropertyDef = mappingDefinition.properties[propertyName];
|
|
135
|
+
// Already seen
|
|
136
|
+
const existingPropertyDef = seenProperties[propertyName];
|
|
137
|
+
if (existingPropertyDef) {
|
|
138
|
+
// Types match
|
|
139
|
+
if (existingPropertyDef.type === newPropertyDef.type) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
// Collision
|
|
143
|
+
throw new Error(`'${name}' contains two mappings with the same property, but each refers to a different type. All matching properties must refer to the same type.`);
|
|
144
|
+
}
|
|
145
|
+
// New
|
|
146
|
+
else {
|
|
147
|
+
seenProperties[propertyName] = newPropertyDef;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=one-of-definition.js.map
|