@skmtc/core 0.0.231 → 0.0.233

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/esm/mod.d.ts CHANGED
@@ -52,6 +52,7 @@ export * from './typescript/EntityType.js';
52
52
  export * from './typescript/FunctionParameter.js';
53
53
  export * from './typescript/identifiers.js';
54
54
  export * from './typescript/keyValues.js';
55
+ export * from './typescript/PathParams.js';
55
56
  export * from './typescript/ReactRouterPathParams.js';
56
57
  export * from './typescript/toDestructuredObject.js';
57
58
  export * from './typescript/toOperationArg.js';
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sCAAsC,CAAA;AACpD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB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CAAqC,CAAA;AACnD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
package/esm/mod.js CHANGED
@@ -52,6 +52,7 @@ export * from './typescript/EntityType.js';
52
52
  export * from './typescript/FunctionParameter.js';
53
53
  export * from './typescript/identifiers.js';
54
54
  export * from './typescript/keyValues.js';
55
+ export * from './typescript/PathParams.js';
55
56
  export * from './typescript/ReactRouterPathParams.js';
56
57
  export * from './typescript/toDestructuredObject.js';
57
58
  export * from './typescript/toOperationArg.js';
@@ -2,7 +2,7 @@ import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefiniton: Definition<TypeSystemValue>;
5
+ typeDefinition: Definition<TypeSystemValue>;
6
6
  destructure: boolean;
7
7
  required?: boolean;
8
8
  };
@@ -12,12 +12,12 @@ type VoidParameter = {
12
12
  };
13
13
  type DestructuredParameter = {
14
14
  type: 'destructured';
15
- typeDefiniton: Definition<TypeSystemObject>;
15
+ typeDefinition: Definition<TypeSystemObject>;
16
16
  };
17
17
  type RegularParameter = {
18
18
  type: 'regular';
19
19
  name: string;
20
- typeDefiniton: Definition<TypeSystemValue>;
20
+ typeDefinition: Definition<TypeSystemValue>;
21
21
  required: boolean;
22
22
  };
23
23
  export declare class FunctionParameter {
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,CAA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IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;CAC7C,CAAA;AACD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB,CAAA;gBAEnB,IAAI,EAAE,UAAU;IA6B5B,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE;IAc1B,SAAS,IAAI,MAAM;IAkBnB,QAAQ,IAAI,MAAM;CAiBnB"}
@@ -10,21 +10,21 @@ export class FunctionParameter {
10
10
  });
11
11
  // @TODO It might be possible to simplify this by adding entityType
12
12
  // to Definition as one its generic parameter types
13
- if (args.typeDefiniton.identifier.entityType.type === 'value') {
13
+ if (args.typeDefinition.identifier.entityType.type === 'value') {
14
14
  throw new Error('Value identifiers cannot be used in type definitions');
15
15
  }
16
16
  this.properties = match(args)
17
- .with({ typeDefiniton: { value: { type: 'void' } } }, () => ({
17
+ .with({ typeDefinition: { value: { type: 'void' } } }, () => ({
18
18
  type: 'void'
19
19
  }))
20
- .with({ typeDefiniton: { value: { type: 'object' }, destructure: true } }, ({ typeDefiniton }) => ({
20
+ .with({ typeDefinition: { value: { type: 'object' } }, destructure: true }, ({ typeDefinition }) => ({
21
21
  type: 'destructured',
22
- typeDefiniton
22
+ typeDefinition
23
23
  }))
24
- .with({ name: P.string }, ({ typeDefiniton, name, required }) => ({
24
+ .with({ name: P.string }, ({ typeDefinition, name, required }) => ({
25
25
  type: 'regular',
26
26
  name,
27
- typeDefiniton,
27
+ typeDefinition,
28
28
  required: required ?? false
29
29
  }))
30
30
  .otherwise(() => {
@@ -35,9 +35,9 @@ export class FunctionParameter {
35
35
  if (this.properties.type === 'void') {
36
36
  return this;
37
37
  }
38
- invariant(this.properties.typeDefiniton.value.type === 'object', 'Only object types can be destructured');
38
+ invariant(this.properties.typeDefinition.value.type === 'object', 'Only object types can be destructured');
39
39
  return new FunctionParameter({
40
- typeDefiniton: this.properties.typeDefiniton,
40
+ typeDefinition: this.properties.typeDefinition,
41
41
  destructure: true
42
42
  });
43
43
  }
@@ -45,8 +45,8 @@ export class FunctionParameter {
45
45
  return match(this.properties)
46
46
  .with({ type: 'void' }, () => [])
47
47
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
48
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
49
- return toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
48
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
49
+ return toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
50
50
  })
51
51
  .otherwise(() => {
52
52
  throw new Error('Invalid parameter');
@@ -58,8 +58,8 @@ export class FunctionParameter {
58
58
  .with({ type: 'regular' }, ({ name }) => {
59
59
  return `${name}`;
60
60
  })
61
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
62
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
61
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
62
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
63
63
  return `{${propertyNames.join(', ')}}`;
64
64
  })
65
65
  .otherwise(() => {
@@ -69,12 +69,12 @@ export class FunctionParameter {
69
69
  toString() {
70
70
  return match(this.properties)
71
71
  .with({ type: 'void' }, () => '')
72
- .with({ type: 'regular' }, ({ name, typeDefiniton, required }) => {
73
- return `${name}${required ? '' : '?'}: ${typeDefiniton.identifier}`;
72
+ .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
73
+ return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
74
74
  })
75
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
76
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
77
- return `{${propertyNames.join(', ')}}: ${typeDefiniton.identifier}`;
75
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
76
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
77
+ return `{${propertyNames.join(', ')}}: ${typeDefinition.identifier}`;
78
78
  })
79
79
  .otherwise(() => {
80
80
  throw new Error('Invalid parameter');
@@ -0,0 +1,23 @@
1
+ import type { CoreContext } from '../context/CoreContext.js';
2
+ import type { ContentSettings } from '../dsl/ContentSettings.js';
3
+ import { Definition } from '../dsl/Definition.js';
4
+ import type { OasObject } from '../oas/object/Object.js';
5
+ import type { TypeSystemArgs, TypeSystemValue } from '../types/TypeSystem.js';
6
+ import { FunctionParameter } from './FunctionParameter.js';
7
+ type ConstructorArgs = {
8
+ context: CoreContext;
9
+ name: string;
10
+ objectSchema: OasObject;
11
+ settings: ContentSettings;
12
+ pathTemplate: string;
13
+ toValue: (args: TypeSystemArgs) => TypeSystemValue;
14
+ };
15
+ export declare class PathParams {
16
+ context: CoreContext;
17
+ typeDefinition: Definition<TypeSystemValue>;
18
+ parameter: FunctionParameter;
19
+ path: string;
20
+ constructor({ context, name, objectSchema, settings, pathTemplate, toValue }: ConstructorArgs);
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=PathParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathParams.d.ts","sourceRoot":"","sources":["../../src/typescript/PathParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,WAAW,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,SAAS,CAAA;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,eAAe,CAAA;CACnD,CAAA;AAED,qBAAa,UAAU;IACrB,OAAO,EAAE,WAAW,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,SAAS,EAAE,iBAAiB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;gBAEA,EACV,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,OAAO,EACR,EAAE,eAAe;CA6BnB"}
@@ -0,0 +1,55 @@
1
+ import { Definition } from '../dsl/Definition.js';
2
+ import { Identifier } from '../dsl/Identifier.js';
3
+ import { capitalize } from '../helpers/strings.js';
4
+ import { FunctionParameter } from './FunctionParameter.js';
5
+ import { toPathTemplate } from './toPathTemplate.js';
6
+ export class PathParams {
7
+ constructor({ context, name, objectSchema, settings, pathTemplate, toValue }) {
8
+ Object.defineProperty(this, "context", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: void 0
13
+ });
14
+ Object.defineProperty(this, "typeDefinition", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "parameter", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ Object.defineProperty(this, "path", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ this.context = context;
33
+ this.typeDefinition = new Definition({
34
+ context,
35
+ identifier: Identifier.createType(capitalize(`${settings.name}Params`)),
36
+ value: toValue({
37
+ context,
38
+ schema: objectSchema,
39
+ destinationPath: settings.exportPath,
40
+ required: true
41
+ })
42
+ });
43
+ this.parameter = new FunctionParameter({
44
+ name,
45
+ typeDefinition: this.typeDefinition,
46
+ destructure: !name,
47
+ required: true
48
+ });
49
+ const queryArg = this.parameter.properties.type === 'regular'
50
+ ? this.parameter.properties.name
51
+ : undefined;
52
+ // @TODO Reconcile pathTemplate with params
53
+ this.path = toPathTemplate(pathTemplate, queryArg);
54
+ }
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.231",
3
+ "version": "0.0.233",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
package/script/mod.d.ts CHANGED
@@ -52,6 +52,7 @@ export * from './typescript/EntityType.js';
52
52
  export * from './typescript/FunctionParameter.js';
53
53
  export * from './typescript/identifiers.js';
54
54
  export * from './typescript/keyValues.js';
55
+ export * from './typescript/PathParams.js';
55
56
  export * from './typescript/ReactRouterPathParams.js';
56
57
  export * from './typescript/toDestructuredObject.js';
57
58
  export * from './typescript/toOperationArg.js';
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CA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CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mCAAmC,CAAA;AACjD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA;AACrD,cAAc,sCAAsC,CAAA;AACpD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,qCAAqC,CAAA;AACnD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
package/script/mod.js CHANGED
@@ -68,6 +68,7 @@ __exportStar(require("./typescript/EntityType.js"), exports);
68
68
  __exportStar(require("./typescript/FunctionParameter.js"), exports);
69
69
  __exportStar(require("./typescript/identifiers.js"), exports);
70
70
  __exportStar(require("./typescript/keyValues.js"), exports);
71
+ __exportStar(require("./typescript/PathParams.js"), exports);
71
72
  __exportStar(require("./typescript/ReactRouterPathParams.js"), exports);
72
73
  __exportStar(require("./typescript/toDestructuredObject.js"), exports);
73
74
  __exportStar(require("./typescript/toOperationArg.js"), exports);
@@ -2,7 +2,7 @@ import type { TypeSystemObject, TypeSystemValue } from '../types/TypeSystem.js';
2
2
  import type { Definition } from '../dsl/Definition.js';
3
3
  type CreateArgs = {
4
4
  name?: string;
5
- typeDefiniton: Definition<TypeSystemValue>;
5
+ typeDefinition: Definition<TypeSystemValue>;
6
6
  destructure: boolean;
7
7
  required?: boolean;
8
8
  };
@@ -12,12 +12,12 @@ type VoidParameter = {
12
12
  };
13
13
  type DestructuredParameter = {
14
14
  type: 'destructured';
15
- typeDefiniton: Definition<TypeSystemObject>;
15
+ typeDefinition: Definition<TypeSystemObject>;
16
16
  };
17
17
  type RegularParameter = {
18
18
  type: 'regular';
19
19
  name: string;
20
- typeDefiniton: Definition<TypeSystemValue>;
20
+ typeDefinition: Definition<TypeSystemValue>;
21
21
  required: boolean;
22
22
  };
23
23
  export declare class FunctionParameter {
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1C,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GACpB,aAAa,GACb,qBAAqB,GACrB,gBAAgB,CAAA;AAEpB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cAAc,CAAA;IACpB,aAAa,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;CAC5C,CAAA;AACD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC1C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB,CAAA;gBAEnB,IAAI,EAAE,UAAU;IA6B5B,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE;IAc1B,SAAS,IAAI,MAAM;IAkBnB,QAAQ,IAAI,MAAM;CAiBnB"}
1
+ {"version":3,"file":"FunctionParameter.d.ts","sourceRoot":"","sources":["../../src/typescript/FunctionParameter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,KAAK,UAAU,GAAG;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GACpB,aAAa,GACb,qBAAqB,GACrB,gBAAgB,CAAA;AAEpB,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,cAAc,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAA;CAC7C,CAAA;AACD,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,iBAAiB;IAC5B,UAAU,EAAE,mBAAmB,CAAA;gBAEnB,IAAI,EAAE,UAAU;IA6B5B,cAAc,IAAI,iBAAiB;IAgBnC,cAAc,IAAI,MAAM,EAAE;IAc1B,SAAS,IAAI,MAAM;IAkBnB,QAAQ,IAAI,MAAM;CAiBnB"}
@@ -16,21 +16,21 @@ class FunctionParameter {
16
16
  });
17
17
  // @TODO It might be possible to simplify this by adding entityType
18
18
  // to Definition as one its generic parameter types
19
- if (args.typeDefiniton.identifier.entityType.type === 'value') {
19
+ if (args.typeDefinition.identifier.entityType.type === 'value') {
20
20
  throw new Error('Value identifiers cannot be used in type definitions');
21
21
  }
22
22
  this.properties = (0, ts_pattern_1.match)(args)
23
- .with({ typeDefiniton: { value: { type: 'void' } } }, () => ({
23
+ .with({ typeDefinition: { value: { type: 'void' } } }, () => ({
24
24
  type: 'void'
25
25
  }))
26
- .with({ typeDefiniton: { value: { type: 'object' }, destructure: true } }, ({ typeDefiniton }) => ({
26
+ .with({ typeDefinition: { value: { type: 'object' } }, destructure: true }, ({ typeDefinition }) => ({
27
27
  type: 'destructured',
28
- typeDefiniton
28
+ typeDefinition
29
29
  }))
30
- .with({ name: ts_pattern_1.P.string }, ({ typeDefiniton, name, required }) => ({
30
+ .with({ name: ts_pattern_1.P.string }, ({ typeDefinition, name, required }) => ({
31
31
  type: 'regular',
32
32
  name,
33
- typeDefiniton,
33
+ typeDefinition,
34
34
  required: required ?? false
35
35
  }))
36
36
  .otherwise(() => {
@@ -41,9 +41,9 @@ class FunctionParameter {
41
41
  if (this.properties.type === 'void') {
42
42
  return this;
43
43
  }
44
- (0, tiny_invariant_1.default)(this.properties.typeDefiniton.value.type === 'object', 'Only object types can be destructured');
44
+ (0, tiny_invariant_1.default)(this.properties.typeDefinition.value.type === 'object', 'Only object types can be destructured');
45
45
  return new FunctionParameter({
46
- typeDefiniton: this.properties.typeDefiniton,
46
+ typeDefinition: this.properties.typeDefinition,
47
47
  destructure: true
48
48
  });
49
49
  }
@@ -51,8 +51,8 @@ class FunctionParameter {
51
51
  return (0, ts_pattern_1.match)(this.properties)
52
52
  .with({ type: 'void' }, () => [])
53
53
  .with({ type: 'regular' }, ({ name }) => [`${name}`])
54
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
55
- return toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
54
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
55
+ return toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
56
56
  })
57
57
  .otherwise(() => {
58
58
  throw new Error('Invalid parameter');
@@ -64,8 +64,8 @@ class FunctionParameter {
64
64
  .with({ type: 'regular' }, ({ name }) => {
65
65
  return `${name}`;
66
66
  })
67
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
68
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
67
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
68
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
69
69
  return `{${propertyNames.join(', ')}}`;
70
70
  })
71
71
  .otherwise(() => {
@@ -75,12 +75,12 @@ class FunctionParameter {
75
75
  toString() {
76
76
  return (0, ts_pattern_1.match)(this.properties)
77
77
  .with({ type: 'void' }, () => '')
78
- .with({ type: 'regular' }, ({ name, typeDefiniton, required }) => {
79
- return `${name}${required ? '' : '?'}: ${typeDefiniton.identifier}`;
78
+ .with({ type: 'regular' }, ({ name, typeDefinition, required }) => {
79
+ return `${name}${required ? '' : '?'}: ${typeDefinition.identifier}`;
80
80
  })
81
- .with({ type: 'destructured' }, ({ typeDefiniton }) => {
82
- const propertyNames = toPropertyNames(typeDefiniton.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
83
- return `{${propertyNames.join(', ')}}: ${typeDefiniton.identifier}`;
81
+ .with({ type: 'destructured' }, ({ typeDefinition }) => {
82
+ const propertyNames = toPropertyNames(typeDefinition.value).map(name => name === `'If-Match'` ? `'If-Match': IfMatch` : name);
83
+ return `{${propertyNames.join(', ')}}: ${typeDefinition.identifier}`;
84
84
  })
85
85
  .otherwise(() => {
86
86
  throw new Error('Invalid parameter');
@@ -0,0 +1,23 @@
1
+ import type { CoreContext } from '../context/CoreContext.js';
2
+ import type { ContentSettings } from '../dsl/ContentSettings.js';
3
+ import { Definition } from '../dsl/Definition.js';
4
+ import type { OasObject } from '../oas/object/Object.js';
5
+ import type { TypeSystemArgs, TypeSystemValue } from '../types/TypeSystem.js';
6
+ import { FunctionParameter } from './FunctionParameter.js';
7
+ type ConstructorArgs = {
8
+ context: CoreContext;
9
+ name: string;
10
+ objectSchema: OasObject;
11
+ settings: ContentSettings;
12
+ pathTemplate: string;
13
+ toValue: (args: TypeSystemArgs) => TypeSystemValue;
14
+ };
15
+ export declare class PathParams {
16
+ context: CoreContext;
17
+ typeDefinition: Definition<TypeSystemValue>;
18
+ parameter: FunctionParameter;
19
+ path: string;
20
+ constructor({ context, name, objectSchema, settings, pathTemplate, toValue }: ConstructorArgs);
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=PathParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathParams.d.ts","sourceRoot":"","sources":["../../src/typescript/PathParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAG1D,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,WAAW,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,SAAS,CAAA;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,eAAe,CAAA;CACnD,CAAA;AAED,qBAAa,UAAU;IACrB,OAAO,EAAE,WAAW,CAAA;IACpB,cAAc,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,SAAS,EAAE,iBAAiB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;gBAEA,EACV,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,OAAO,EACR,EAAE,eAAe;CA6BnB"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathParams = void 0;
4
+ const Definition_js_1 = require("../dsl/Definition.js");
5
+ const Identifier_js_1 = require("../dsl/Identifier.js");
6
+ const strings_js_1 = require("../helpers/strings.js");
7
+ const FunctionParameter_js_1 = require("./FunctionParameter.js");
8
+ const toPathTemplate_js_1 = require("./toPathTemplate.js");
9
+ class PathParams {
10
+ constructor({ context, name, objectSchema, settings, pathTemplate, toValue }) {
11
+ Object.defineProperty(this, "context", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
17
+ Object.defineProperty(this, "typeDefinition", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "parameter", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "path", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ this.context = context;
36
+ this.typeDefinition = new Definition_js_1.Definition({
37
+ context,
38
+ identifier: Identifier_js_1.Identifier.createType((0, strings_js_1.capitalize)(`${settings.name}Params`)),
39
+ value: toValue({
40
+ context,
41
+ schema: objectSchema,
42
+ destinationPath: settings.exportPath,
43
+ required: true
44
+ })
45
+ });
46
+ this.parameter = new FunctionParameter_js_1.FunctionParameter({
47
+ name,
48
+ typeDefinition: this.typeDefinition,
49
+ destructure: !name,
50
+ required: true
51
+ });
52
+ const queryArg = this.parameter.properties.type === 'regular'
53
+ ? this.parameter.properties.name
54
+ : undefined;
55
+ // @TODO Reconcile pathTemplate with params
56
+ this.path = (0, toPathTemplate_js_1.toPathTemplate)(pathTemplate, queryArg);
57
+ }
58
+ }
59
+ exports.PathParams = PathParams;