@takeshape/schema 11.73.0 → 11.76.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.
Files changed (109) hide show
  1. package/dist/builtin-schema.js +1 -0
  2. package/dist/models/runtime-schema.js +1 -0
  3. package/dist/project-schema/latest.d.ts +6 -1
  4. package/dist/project-schema/v3.48.0.d.ts +6 -1
  5. package/dist/project-schema/v3.49.0.d.ts +6 -1
  6. package/dist/project-schema/v3.50.0.d.ts +6 -1
  7. package/dist/project-schema/v3.51.0.d.ts +6 -1
  8. package/dist/project-schema/v3.52.0.d.ts +6 -1
  9. package/dist/project-schema/v3.53.0.d.ts +6 -1
  10. package/dist/project-schema/v3.54.0.d.ts +6 -1
  11. package/dist/schemas/project-schema/experimental.json +20 -0
  12. package/dist/util/expressions.js +2 -2
  13. package/package.json +6 -6
  14. package/dist/__tests__/_examples.test.d.ts +0 -1
  15. package/dist/__tests__/_examples.test.js +0 -77
  16. package/dist/__tests__/agents.test.d.ts +0 -1
  17. package/dist/__tests__/agents.test.js +0 -163
  18. package/dist/__tests__/api-version.test.d.ts +0 -1
  19. package/dist/__tests__/api-version.test.js +0 -24
  20. package/dist/__tests__/builtin-schema.test.d.ts +0 -1
  21. package/dist/__tests__/builtin-schema.test.js +0 -18
  22. package/dist/__tests__/content-schema-transform.test.d.ts +0 -1
  23. package/dist/__tests__/content-schema-transform.test.js +0 -522
  24. package/dist/__tests__/create-input-schema.test.d.ts +0 -1
  25. package/dist/__tests__/create-input-schema.test.js +0 -184
  26. package/dist/__tests__/enum.test.d.ts +0 -1
  27. package/dist/__tests__/enum.test.js +0 -36
  28. package/dist/__tests__/flatten-templates.test.d.ts +0 -1
  29. package/dist/__tests__/flatten-templates.test.js +0 -40
  30. package/dist/__tests__/get-is-leaf.test.d.ts +0 -1
  31. package/dist/__tests__/get-is-leaf.test.js +0 -50
  32. package/dist/__tests__/interfaces.test.d.ts +0 -1
  33. package/dist/__tests__/interfaces.test.js +0 -219
  34. package/dist/__tests__/migration.test.d.ts +0 -1
  35. package/dist/__tests__/migration.test.js +0 -34
  36. package/dist/__tests__/mocks.test.d.ts +0 -1
  37. package/dist/__tests__/mocks.test.js +0 -24
  38. package/dist/__tests__/refs.test.d.ts +0 -1
  39. package/dist/__tests__/refs.test.js +0 -813
  40. package/dist/__tests__/relationships.test.d.ts +0 -1
  41. package/dist/__tests__/relationships.test.js +0 -638
  42. package/dist/__tests__/schema-transform.test.d.ts +0 -1
  43. package/dist/__tests__/schema-transform.test.js +0 -205
  44. package/dist/__tests__/schema-util.test.d.ts +0 -1
  45. package/dist/__tests__/schema-util.test.js +0 -1731
  46. package/dist/__tests__/service-dependencies.test.d.ts +0 -1
  47. package/dist/__tests__/service-dependencies.test.js +0 -360
  48. package/dist/__tests__/unions.test.d.ts +0 -1
  49. package/dist/__tests__/unions.test.js +0 -44
  50. package/dist/__tests__/validate.test.d.ts +0 -1
  51. package/dist/__tests__/validate.test.js +0 -1980
  52. package/dist/__tests__/workflows.test.d.ts +0 -3
  53. package/dist/__tests__/workflows.test.js +0 -149
  54. package/dist/layers/__tests__/layers.test.d.ts +0 -1
  55. package/dist/layers/__tests__/layers.test.js +0 -38
  56. package/dist/migration/to/__tests__/v3.10.0.test.d.ts +0 -1
  57. package/dist/migration/to/__tests__/v3.10.0.test.js +0 -90
  58. package/dist/migration/to/__tests__/v3.12.3.test.d.ts +0 -1
  59. package/dist/migration/to/__tests__/v3.12.3.test.js +0 -103
  60. package/dist/migration/to/__tests__/v3.17.test.d.ts +0 -1
  61. package/dist/migration/to/__tests__/v3.17.test.js +0 -71
  62. package/dist/migration/to/__tests__/v3.34.0.test.d.ts +0 -1
  63. package/dist/migration/to/__tests__/v3.34.0.test.js +0 -240
  64. package/dist/migration/to/__tests__/v3.39.0.test.d.ts +0 -1
  65. package/dist/migration/to/__tests__/v3.39.0.test.js +0 -116
  66. package/dist/migration/to/__tests__/v3.46.0.test.d.ts +0 -1
  67. package/dist/migration/to/__tests__/v3.46.0.test.js +0 -59
  68. package/dist/models/__tests__/fixtures.d.ts +0 -15
  69. package/dist/models/__tests__/fixtures.js +0 -56
  70. package/dist/models/__tests__/query.test.d.ts +0 -1
  71. package/dist/models/__tests__/query.test.js +0 -19
  72. package/dist/models/__tests__/runtime-schema.test.d.ts +0 -1
  73. package/dist/models/__tests__/runtime-schema.test.js +0 -43
  74. package/dist/models/__tests__/shape.test.d.ts +0 -1
  75. package/dist/models/__tests__/shape.test.js +0 -24
  76. package/dist/resolvers/ai/__tests__/rag-query.test.d.ts +0 -1
  77. package/dist/resolvers/ai/__tests__/rag-query.test.js +0 -49
  78. package/dist/services/__tests__/services.test.d.ts +0 -1
  79. package/dist/services/__tests__/services.test.js +0 -113
  80. package/dist/template-shapes/__tests__/index.test.d.ts +0 -1
  81. package/dist/template-shapes/__tests__/index.test.js +0 -40
  82. package/dist/template-shapes/__tests__/names.test.d.ts +0 -1
  83. package/dist/template-shapes/__tests__/names.test.js +0 -19
  84. package/dist/template-shapes/__tests__/templates.test.d.ts +0 -1
  85. package/dist/template-shapes/__tests__/templates.test.js +0 -80
  86. package/dist/template-shapes/__tests__/where.test.d.ts +0 -1
  87. package/dist/template-shapes/__tests__/where.test.js +0 -218
  88. package/dist/types/__tests__/utils.test.d.ts +0 -1
  89. package/dist/types/__tests__/utils.test.js +0 -159
  90. package/dist/util/__tests__/api-indexing.test.d.ts +0 -1
  91. package/dist/util/__tests__/api-indexing.test.js +0 -129
  92. package/dist/util/__tests__/detect-cycles.test.d.ts +0 -1
  93. package/dist/util/__tests__/detect-cycles.test.js +0 -193
  94. package/dist/util/__tests__/expressions.test.d.ts +0 -1
  95. package/dist/util/__tests__/expressions.test.js +0 -172
  96. package/dist/util/__tests__/find-shape-at-path.test.d.ts +0 -1
  97. package/dist/util/__tests__/find-shape-at-path.test.js +0 -41
  98. package/dist/util/__tests__/form-config.test.d.ts +0 -1
  99. package/dist/util/__tests__/form-config.test.js +0 -196
  100. package/dist/util/__tests__/get-return-shape.test.d.ts +0 -1
  101. package/dist/util/__tests__/get-return-shape.test.js +0 -27
  102. package/dist/util/__tests__/has-args.test.d.ts +0 -1
  103. package/dist/util/__tests__/has-args.test.js +0 -46
  104. package/dist/util/__tests__/merge.test.d.ts +0 -1
  105. package/dist/util/__tests__/merge.test.js +0 -1074
  106. package/dist/util/__tests__/patch-schema.test.d.ts +0 -1
  107. package/dist/util/__tests__/patch-schema.test.js +0 -82
  108. package/dist/util/__tests__/shapes.test.d.ts +0 -1
  109. package/dist/util/__tests__/shapes.test.js +0 -30
@@ -418,6 +418,7 @@ export const builtInShapes = {
418
418
  done: { type: 'boolean' },
419
419
  currentStateId: { type: 'string' },
420
420
  chatSessionIds: { type: 'object' },
421
+ sessionMemory: { type: 'object' },
421
422
  stateOutputs: { type: 'object' },
422
423
  currentValue: { type: 'object' }
423
424
  }
@@ -17,6 +17,7 @@ export class RuntimeSchema {
17
17
  }
18
18
  get runtimeSchemaJson() {
19
19
  if (!this.#runtimeSchema) {
20
+ // biome-ignore lint/suspicious/noConsole: ignore
20
21
  this.#runtimeSchema = buildRuntimeSchema(this.#userSchema, this.#layers, console.log);
21
22
  }
22
23
  return this.#runtimeSchema;
@@ -348,7 +348,7 @@ export type RemovePropertyKeyPatterns = MinimatchPattern[];
348
348
  */
349
349
  export type StripMarkdown = boolean;
350
350
  export type AgentChatHistoryConfig = AgentChatHistoryRetain | AgentChatHistorySummarize | AgentChatHistoryClear;
351
- export type AgentStateSessionMemoryLocation = AgentStateSessionMemoryLocationArtifact | AgentStateSessionMemoryLocationStaticValue;
351
+ export type AgentStateSessionMemoryLocation = AgentStateSessionMemoryLocationContent | AgentStateSessionMemoryLocationArtifact | AgentStateSessionMemoryLocationStaticValue;
352
352
  export type AgentStateSessionMemory = AgentStateSessionMemoryLocation[];
353
353
  export type GuardID = string;
354
354
  /**
@@ -1909,6 +1909,11 @@ export interface AgentChatHistorySummarize {
1909
1909
  export interface AgentChatHistoryClear {
1910
1910
  type: 'clear';
1911
1911
  }
1912
+ export interface AgentStateSessionMemoryLocationContent {
1913
+ type: 'content';
1914
+ memoryKey: string;
1915
+ path?: string;
1916
+ }
1912
1917
  export interface AgentStateSessionMemoryLocationArtifact {
1913
1918
  type: 'artifactValue';
1914
1919
  memoryKey: string;
@@ -323,7 +323,7 @@ export type RemovePropertyKeyPatternsV3_48_0 = MinimatchPatternV3_48_0[];
323
323
  */
324
324
  export type StripMarkdownV3_48_0 = boolean;
325
325
  export type AgentChatHistoryConfigV3_48_0 = AgentChatHistoryRetainV3_48_0 | AgentChatHistorySummarizeV3_48_0 | AgentChatHistoryClearV3_48_0;
326
- export type AgentStateSessionMemoryLocationV3_48_0 = AgentStateSessionMemoryLocationArtifactV3_48_0 | AgentStateSessionMemoryLocationStaticValueV3_48_0;
326
+ export type AgentStateSessionMemoryLocationV3_48_0 = AgentStateSessionMemoryLocationContentV3_48_0 | AgentStateSessionMemoryLocationArtifactV3_48_0 | AgentStateSessionMemoryLocationStaticValueV3_48_0;
327
327
  export type AgentStateSessionMemoryV3_48_0 = AgentStateSessionMemoryLocationV3_48_0[];
328
328
  export type GuardIDV3_48_0 = string;
329
329
  /**
@@ -1757,6 +1757,11 @@ export interface AgentChatHistorySummarizeV3_48_0 {
1757
1757
  export interface AgentChatHistoryClearV3_48_0 {
1758
1758
  type: 'clear';
1759
1759
  }
1760
+ export interface AgentStateSessionMemoryLocationContentV3_48_0 {
1761
+ type: 'content';
1762
+ memoryKey: string;
1763
+ path?: string;
1764
+ }
1760
1765
  export interface AgentStateSessionMemoryLocationArtifactV3_48_0 {
1761
1766
  type: 'artifactValue';
1762
1767
  memoryKey: string;
@@ -323,7 +323,7 @@ export type RemovePropertyKeyPatternsV3_49_0 = MinimatchPatternV3_49_0[];
323
323
  */
324
324
  export type StripMarkdownV3_49_0 = boolean;
325
325
  export type AgentChatHistoryConfigV3_49_0 = AgentChatHistoryRetainV3_49_0 | AgentChatHistorySummarizeV3_49_0 | AgentChatHistoryClearV3_49_0;
326
- export type AgentStateSessionMemoryLocationV3_49_0 = AgentStateSessionMemoryLocationArtifactV3_49_0 | AgentStateSessionMemoryLocationStaticValueV3_49_0;
326
+ export type AgentStateSessionMemoryLocationV3_49_0 = AgentStateSessionMemoryLocationContentV3_49_0 | AgentStateSessionMemoryLocationArtifactV3_49_0 | AgentStateSessionMemoryLocationStaticValueV3_49_0;
327
327
  export type AgentStateSessionMemoryV3_49_0 = AgentStateSessionMemoryLocationV3_49_0[];
328
328
  export type GuardIDV3_49_0 = string;
329
329
  /**
@@ -1757,6 +1757,11 @@ export interface AgentChatHistorySummarizeV3_49_0 {
1757
1757
  export interface AgentChatHistoryClearV3_49_0 {
1758
1758
  type: 'clear';
1759
1759
  }
1760
+ export interface AgentStateSessionMemoryLocationContentV3_49_0 {
1761
+ type: 'content';
1762
+ memoryKey: string;
1763
+ path?: string;
1764
+ }
1760
1765
  export interface AgentStateSessionMemoryLocationArtifactV3_49_0 {
1761
1766
  type: 'artifactValue';
1762
1767
  memoryKey: string;
@@ -335,7 +335,7 @@ export type RemovePropertyKeyPatternsV3_50_0 = MinimatchPatternV3_50_0[];
335
335
  */
336
336
  export type StripMarkdownV3_50_0 = boolean;
337
337
  export type AgentChatHistoryConfigV3_50_0 = AgentChatHistoryRetainV3_50_0 | AgentChatHistorySummarizeV3_50_0 | AgentChatHistoryClearV3_50_0;
338
- export type AgentStateSessionMemoryLocationV3_50_0 = AgentStateSessionMemoryLocationArtifactV3_50_0 | AgentStateSessionMemoryLocationStaticValueV3_50_0;
338
+ export type AgentStateSessionMemoryLocationV3_50_0 = AgentStateSessionMemoryLocationContentV3_50_0 | AgentStateSessionMemoryLocationArtifactV3_50_0 | AgentStateSessionMemoryLocationStaticValueV3_50_0;
339
339
  export type AgentStateSessionMemoryV3_50_0 = AgentStateSessionMemoryLocationV3_50_0[];
340
340
  export type GuardIDV3_50_0 = string;
341
341
  /**
@@ -1809,6 +1809,11 @@ export interface AgentChatHistorySummarizeV3_50_0 {
1809
1809
  export interface AgentChatHistoryClearV3_50_0 {
1810
1810
  type: 'clear';
1811
1811
  }
1812
+ export interface AgentStateSessionMemoryLocationContentV3_50_0 {
1813
+ type: 'content';
1814
+ memoryKey: string;
1815
+ path?: string;
1816
+ }
1812
1817
  export interface AgentStateSessionMemoryLocationArtifactV3_50_0 {
1813
1818
  type: 'artifactValue';
1814
1819
  memoryKey: string;
@@ -335,7 +335,7 @@ export type RemovePropertyKeyPatternsV3_51_0 = MinimatchPatternV3_51_0[];
335
335
  */
336
336
  export type StripMarkdownV3_51_0 = boolean;
337
337
  export type AgentChatHistoryConfigV3_51_0 = AgentChatHistoryRetainV3_51_0 | AgentChatHistorySummarizeV3_51_0 | AgentChatHistoryClearV3_51_0;
338
- export type AgentStateSessionMemoryLocationV3_51_0 = AgentStateSessionMemoryLocationArtifactV3_51_0 | AgentStateSessionMemoryLocationStaticValueV3_51_0;
338
+ export type AgentStateSessionMemoryLocationV3_51_0 = AgentStateSessionMemoryLocationContentV3_51_0 | AgentStateSessionMemoryLocationArtifactV3_51_0 | AgentStateSessionMemoryLocationStaticValueV3_51_0;
339
339
  export type AgentStateSessionMemoryV3_51_0 = AgentStateSessionMemoryLocationV3_51_0[];
340
340
  export type GuardIDV3_51_0 = string;
341
341
  /**
@@ -1809,6 +1809,11 @@ export interface AgentChatHistorySummarizeV3_51_0 {
1809
1809
  export interface AgentChatHistoryClearV3_51_0 {
1810
1810
  type: 'clear';
1811
1811
  }
1812
+ export interface AgentStateSessionMemoryLocationContentV3_51_0 {
1813
+ type: 'content';
1814
+ memoryKey: string;
1815
+ path?: string;
1816
+ }
1812
1817
  export interface AgentStateSessionMemoryLocationArtifactV3_51_0 {
1813
1818
  type: 'artifactValue';
1814
1819
  memoryKey: string;
@@ -335,7 +335,7 @@ export type RemovePropertyKeyPatternsV3_52_0 = MinimatchPatternV3_52_0[];
335
335
  */
336
336
  export type StripMarkdownV3_52_0 = boolean;
337
337
  export type AgentChatHistoryConfigV3_52_0 = AgentChatHistoryRetainV3_52_0 | AgentChatHistorySummarizeV3_52_0 | AgentChatHistoryClearV3_52_0;
338
- export type AgentStateSessionMemoryLocationV3_52_0 = AgentStateSessionMemoryLocationArtifactV3_52_0 | AgentStateSessionMemoryLocationStaticValueV3_52_0;
338
+ export type AgentStateSessionMemoryLocationV3_52_0 = AgentStateSessionMemoryLocationContentV3_52_0 | AgentStateSessionMemoryLocationArtifactV3_52_0 | AgentStateSessionMemoryLocationStaticValueV3_52_0;
339
339
  export type AgentStateSessionMemoryV3_52_0 = AgentStateSessionMemoryLocationV3_52_0[];
340
340
  export type GuardIDV3_52_0 = string;
341
341
  /**
@@ -1809,6 +1809,11 @@ export interface AgentChatHistorySummarizeV3_52_0 {
1809
1809
  export interface AgentChatHistoryClearV3_52_0 {
1810
1810
  type: 'clear';
1811
1811
  }
1812
+ export interface AgentStateSessionMemoryLocationContentV3_52_0 {
1813
+ type: 'content';
1814
+ memoryKey: string;
1815
+ path?: string;
1816
+ }
1812
1817
  export interface AgentStateSessionMemoryLocationArtifactV3_52_0 {
1813
1818
  type: 'artifactValue';
1814
1819
  memoryKey: string;
@@ -344,7 +344,7 @@ export type RemovePropertyKeyPatternsV3_53_0 = MinimatchPatternV3_53_0[];
344
344
  */
345
345
  export type StripMarkdownV3_53_0 = boolean;
346
346
  export type AgentChatHistoryConfigV3_53_0 = AgentChatHistoryRetainV3_53_0 | AgentChatHistorySummarizeV3_53_0 | AgentChatHistoryClearV3_53_0;
347
- export type AgentStateSessionMemoryLocationV3_53_0 = AgentStateSessionMemoryLocationArtifactV3_53_0 | AgentStateSessionMemoryLocationStaticValueV3_53_0;
347
+ export type AgentStateSessionMemoryLocationV3_53_0 = AgentStateSessionMemoryLocationContentV3_53_0 | AgentStateSessionMemoryLocationArtifactV3_53_0 | AgentStateSessionMemoryLocationStaticValueV3_53_0;
348
348
  export type AgentStateSessionMemoryV3_53_0 = AgentStateSessionMemoryLocationV3_53_0[];
349
349
  export type GuardIDV3_53_0 = string;
350
350
  /**
@@ -1890,6 +1890,11 @@ export interface AgentChatHistorySummarizeV3_53_0 {
1890
1890
  export interface AgentChatHistoryClearV3_53_0 {
1891
1891
  type: 'clear';
1892
1892
  }
1893
+ export interface AgentStateSessionMemoryLocationContentV3_53_0 {
1894
+ type: 'content';
1895
+ memoryKey: string;
1896
+ path?: string;
1897
+ }
1893
1898
  export interface AgentStateSessionMemoryLocationArtifactV3_53_0 {
1894
1899
  type: 'artifactValue';
1895
1900
  memoryKey: string;
@@ -348,7 +348,7 @@ export type RemovePropertyKeyPatternsV3_54_0 = MinimatchPatternV3_54_0[];
348
348
  */
349
349
  export type StripMarkdownV3_54_0 = boolean;
350
350
  export type AgentChatHistoryConfigV3_54_0 = AgentChatHistoryRetainV3_54_0 | AgentChatHistorySummarizeV3_54_0 | AgentChatHistoryClearV3_54_0;
351
- export type AgentStateSessionMemoryLocationV3_54_0 = AgentStateSessionMemoryLocationArtifactV3_54_0 | AgentStateSessionMemoryLocationStaticValueV3_54_0;
351
+ export type AgentStateSessionMemoryLocationV3_54_0 = AgentStateSessionMemoryLocationContentV3_54_0 | AgentStateSessionMemoryLocationArtifactV3_54_0 | AgentStateSessionMemoryLocationStaticValueV3_54_0;
352
352
  export type AgentStateSessionMemoryV3_54_0 = AgentStateSessionMemoryLocationV3_54_0[];
353
353
  export type GuardIDV3_54_0 = string;
354
354
  /**
@@ -1909,6 +1909,11 @@ export interface AgentChatHistorySummarizeV3_54_0 {
1909
1909
  export interface AgentChatHistoryClearV3_54_0 {
1910
1910
  type: 'clear';
1911
1911
  }
1912
+ export interface AgentStateSessionMemoryLocationContentV3_54_0 {
1913
+ type: 'content';
1914
+ memoryKey: string;
1915
+ path?: string;
1916
+ }
1912
1917
  export interface AgentStateSessionMemoryLocationArtifactV3_54_0 {
1913
1918
  type: 'artifactValue';
1914
1919
  memoryKey: string;
@@ -283,6 +283,9 @@
283
283
  "propertyName": "type"
284
284
  },
285
285
  "oneOf": [
286
+ {
287
+ "$ref": "#/definitions/agentStateSessionMemoryLocationContent"
288
+ },
286
289
  {
287
290
  "$ref": "#/definitions/agentStateSessionMemoryLocationArtifact"
288
291
  },
@@ -325,6 +328,23 @@
325
328
  "required": ["type", "memoryKey"],
326
329
  "additionalProperties": false
327
330
  },
331
+ "agentStateSessionMemoryLocationContent": {
332
+ "title": "Agent State Session Memory Location Content",
333
+ "type": "object",
334
+ "properties": {
335
+ "type": {
336
+ "enum": ["content"]
337
+ },
338
+ "memoryKey": {
339
+ "type": "string"
340
+ },
341
+ "path": {
342
+ "type": "string"
343
+ }
344
+ },
345
+ "required": ["type", "memoryKey"],
346
+ "additionalProperties": false
347
+ },
328
348
  "agentAiStateInputArg": {
329
349
  "title": "Agent AI State Input Argument",
330
350
  "type": "object",
@@ -38,11 +38,11 @@ const binops = {
38
38
  // return a & b;
39
39
  // },
40
40
  '=='(a, b) {
41
- // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
41
+ // biome-ignore lint/suspicious/noDoubleEquals: ignore
42
42
  return a == b;
43
43
  },
44
44
  '!='(a, b) {
45
- // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
45
+ // biome-ignore lint/suspicious/noDoubleEquals: ignore
46
46
  return a != b;
47
47
  },
48
48
  '==='(a, b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/schema",
3
- "version": "11.73.0",
3
+ "version": "11.76.0",
4
4
  "description": "TakeShape Schema",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -57,9 +57,9 @@
57
57
  "p-reduce": "^2.1.0",
58
58
  "semver": "^7.3.2",
59
59
  "tiny-invariant": "^1.2.0",
60
- "@takeshape/errors": "11.73.0",
61
- "@takeshape/util": "11.73.0",
62
- "@takeshape/json-schema": "11.73.0"
60
+ "@takeshape/errors": "11.76.0",
61
+ "@takeshape/json-schema": "11.76.0",
62
+ "@takeshape/util": "11.76.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@takeshape/json-schema-to-typescript": "^11.0.0",
@@ -76,13 +76,13 @@
76
76
  "json-schema-to-ts": "^3.1.1",
77
77
  "meow": "^9.0.0",
78
78
  "shortid": "^2.2.15",
79
- "@takeshape/infra": "11.73.0"
79
+ "@takeshape/infra": "11.76.0"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=20"
83
83
  },
84
84
  "scripts": {
85
- "build": "tsc --build tsconfig.build.json",
85
+ "build": "tsc --project tsconfig.build.json",
86
86
  "postbuild": "find './src/schemas/project-schema/' -maxdepth 1 -name '*.json' -exec rsync --quiet '{}' dist/schemas/project-schema/ \\; && find './src/schemas/' -maxdepth 1 -name '*.json' -exec rsync --quiet '{}' dist/schemas/ \\;",
87
87
  "prebuild:ci": "pnpm clean",
88
88
  "build:ci": "pnpm build --noCheck",
@@ -1 +0,0 @@
1
- export {};
@@ -1,77 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { DEFAULT_ENTITLEMENTS } from '@takeshape/util';
4
- import glob from 'glob';
5
- import pick from 'lodash/pick.js';
6
- import coerce from 'semver/functions/coerce.js';
7
- import compare from 'semver/functions/compare.js';
8
- import { describe, expect, test } from 'vitest';
9
- import { createMockSchema } from "../mocks.js";
10
- import { migrateToLatestProjectSchema } from "../project-schema/migrate.js";
11
- import { validateSchema, validateSchemaSyntax } from "../validate/validate.js";
12
- const examplesPath = path.join(__dirname, '../../examples');
13
- const readSchema = (filePath) => JSON.parse(fs.readFileSync(path.join(examplesPath, filePath), 'utf-8'));
14
- const writeSchema = (filePath, content) => fs.writeFileSync(path.join(examplesPath, filePath), JSON.stringify(content, null, 2), { encoding: 'utf8' });
15
- const sourceFiles = glob.sync('source/**/*.json', { cwd: examplesPath });
16
- const sources = sourceFiles
17
- .map((sourceFilePath) => {
18
- const schema = readSchema(sourceFilePath);
19
- return [coerce(schema.schemaVersion ?? '1')?.version, path.basename(sourceFilePath), schema, sourceFilePath];
20
- })
21
- .sort(([a], [b]) => compare(a, b));
22
- const migrationContext = {
23
- encryptFn() {
24
- return 'abc';
25
- },
26
- decryptFn() {
27
- return { token: 'xyz' };
28
- },
29
- async generateDataKeyFn() {
30
- return 'supersecret';
31
- }
32
- };
33
- function isLayerPath(pathStr) {
34
- return pathStr.includes('/layers/');
35
- }
36
- function layerToProjectSchema(layerSchema) {
37
- return createMockSchema('project-id', layerSchema);
38
- }
39
- async function migrateLayer(schema) {
40
- return pick(await migrateToLatestProjectSchema(migrationContext, layerToProjectSchema(schema)), [
41
- 'shapes',
42
- 'queries',
43
- 'mutations',
44
- 'schemaVersion'
45
- ]);
46
- }
47
- describe.each(sources)('%s - %s', (_, fileName, schema, sourceFilePath) => {
48
- const isLayer = isLayerPath(sourceFilePath);
49
- const latestFilePath = isLayer ? `latest/layers/${fileName}` : `latest/${fileName}`;
50
- test('validate source schema', () => {
51
- const projectSchema = isLayer ? layerToProjectSchema(schema) : schema;
52
- const { errors } = validateSchemaSyntax(projectSchema);
53
- expect(errors).toBe(undefined);
54
- });
55
- test('migrate source schema to latest', async () => {
56
- const migratedSchema = await (isLayer
57
- ? migrateLayer(schema)
58
- : migrateToLatestProjectSchema(migrationContext, schema));
59
- // @ts-expect-error
60
- if (expect.getState().snapshotState._updateSnapshot === 'all') {
61
- console.info(`Updating examples/latest/${fileName}`);
62
- writeSchema(latestFilePath, migratedSchema);
63
- }
64
- else {
65
- const migratedSchemaSnapshot = readSchema(latestFilePath);
66
- expect(migratedSchema).toEqual(migratedSchemaSnapshot);
67
- }
68
- });
69
- test('validate migrated schema', async () => {
70
- const migratedSchemaSnapshot = readSchema(latestFilePath);
71
- const projectSchema = isLayer ? layerToProjectSchema(migratedSchemaSnapshot) : migratedSchemaSnapshot;
72
- const { errors } = isLayer
73
- ? validateSchemaSyntax(projectSchema)
74
- : await validateSchema({ entitlements: DEFAULT_ENTITLEMENTS }, projectSchema);
75
- expect(errors).toBe(undefined);
76
- });
77
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,163 +0,0 @@
1
- import agentSchemaJSON from '@takeshape/schema/examples/latest/agent-schema.json';
2
- import blogSchemaJSON from '@takeshape/schema/examples/latest/blog-schema.json';
3
- import { describe, expect, test } from 'vitest';
4
- import { addAiQueries, createArgs, getAgentEndStates, getAgentEndTransitions, getInspectAgentSessionQueryName } from "../agents.js";
5
- const agentSchema = agentSchemaJSON;
6
- const blogSchema = blogSchemaJSON;
7
- const findDogColor = agentSchema['ai-experimental'].agents.findDogColor;
8
- describe('getAgentEndTransitions', () => {
9
- test('chat', () => {
10
- expect(getAgentEndTransitions(agentSchema['ai-experimental'].agents.chat)).toEqual([
11
- {
12
- originStateId: '3pjuyB47X',
13
- type: 'done'
14
- }
15
- ]);
16
- });
17
- test('findDogColor', () => {
18
- expect(getAgentEndTransitions(agentSchema['ai-experimental'].agents.findDogColor)).toEqual([
19
- {
20
- originStateId: 'ddd',
21
- type: 'done'
22
- },
23
- {
24
- originStateId: 'eee',
25
- type: 'done'
26
- }
27
- ]);
28
- });
29
- });
30
- describe('getAgentEndStates', () => {
31
- test('chat', () => {
32
- expect(getAgentEndStates(agentSchema['ai-experimental'].agents.chat)).toEqual(new Set(['3pjuyB47X']));
33
- });
34
- test('findDogColor', () => {
35
- expect(getAgentEndStates(agentSchema['ai-experimental'].agents.findDogColor)).toEqual(new Set(['ddd', 'eee']));
36
- });
37
- });
38
- describe('getInspectAgentSessionQueryName', () => {
39
- test('it works', () => {
40
- expect(getInspectAgentSessionQueryName('chatWithGreg')).toEqual('inspectChatWithGreg');
41
- });
42
- });
43
- describe('addAiQueries', () => {
44
- const newSchema = addAiQueries(agentSchema);
45
- test('chat', () => {
46
- expect(newSchema.mutations.chat).toEqual({
47
- args: {
48
- properties: {
49
- input: {
50
- type: 'string',
51
- description: 'Input text for the agent'
52
- },
53
- sessionId: {
54
- type: 'string',
55
- description: 'Session ID to continue existing session with this agent'
56
- }
57
- },
58
- required: ['input'],
59
- type: 'object'
60
- },
61
- resolver: {
62
- agentName: 'chat',
63
- name: 'ai:runAgent'
64
- },
65
- shape: 'TSChatResponse'
66
- });
67
- expect(newSchema.queries.inspectChat).toEqual({
68
- args: {
69
- properties: {
70
- sessionId: {
71
- type: 'string'
72
- }
73
- },
74
- required: ['sessionId'],
75
- type: 'object'
76
- },
77
- description: 'Inspect a session for the chat agent',
78
- resolver: {
79
- agentName: 'chat',
80
- name: 'ai:inspectAgentSession'
81
- },
82
- shape: 'TSAgentSession'
83
- });
84
- });
85
- test('findDogColor', () => {
86
- expect(newSchema.mutations.findDogColor).toEqual({
87
- args: {
88
- properties: {
89
- input: {
90
- type: 'string'
91
- }
92
- },
93
- required: ['input'],
94
- type: 'object'
95
- },
96
- description: "AI Agent finds a dog's color based on its name",
97
- resolver: {
98
- agentName: 'findDogColor',
99
- name: 'ai:runAgent'
100
- },
101
- shape: 'string'
102
- });
103
- expect(newSchema.queries.inspectFindDogColor).toEqual(undefined);
104
- });
105
- test('no agents', () => {
106
- expect(Object.values(addAiQueries(blogSchema).queries).length).toEqual(Object.values(blogSchema.queries).length);
107
- });
108
- });
109
- describe('createArgs', () => {
110
- test('deals with duplicates', () => {
111
- expect(createArgs({
112
- ...findDogColor,
113
- api: {
114
- type: 'generate',
115
- arguments: [
116
- {
117
- argName: 'foo',
118
- argType: 'string'
119
- },
120
- {
121
- argName: 'foo',
122
- argType: 'number'
123
- }
124
- ]
125
- }
126
- })).toEqual({
127
- properties: {
128
- foo: {
129
- type: 'string'
130
- }
131
- },
132
- required: [],
133
- type: 'object'
134
- });
135
- });
136
- test('overwrites chat default args', () => {
137
- expect(createArgs({
138
- ...findDogColor,
139
- api: {
140
- type: 'chat',
141
- arguments: [
142
- {
143
- argName: 'input',
144
- argType: 'number'
145
- }
146
- ]
147
- }
148
- })).toEqual({
149
- properties: {
150
- input: {
151
- type: 'string',
152
- description: 'Input text for the agent'
153
- },
154
- sessionId: {
155
- type: 'string',
156
- description: 'Session ID to continue existing session with this agent'
157
- }
158
- },
159
- required: ['input'],
160
- type: 'object'
161
- });
162
- });
163
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import gte from 'semver/functions/gte.js';
2
- import { expect, test } from 'vitest';
3
- import { createVersionPredicate, whereClauseEnabled, workflowsEnabled } from "../api-version.js";
4
- import { CURRENT_API_VERSION, LEGACY_API_VERSION } from "../versions.js";
5
- test('workflowsEnabled - new api', () => {
6
- expect(workflowsEnabled(CURRENT_API_VERSION)).toBe(true);
7
- });
8
- test('workflowsEnabled - legacy api', () => {
9
- expect(workflowsEnabled(LEGACY_API_VERSION)).toBe(false);
10
- });
11
- test('whereClauseEnabled - new api', () => {
12
- expect(whereClauseEnabled(CURRENT_API_VERSION)).toBe(true);
13
- });
14
- test('whereClauseEnabled - legacy api', () => {
15
- expect(whereClauseEnabled(LEGACY_API_VERSION)).toBe(false);
16
- });
17
- test('createVersionPredicate - throw feature version coercion error', () => {
18
- const errorPredicate = () => createVersionPredicate('bogus', gte)('2');
19
- expect(errorPredicate).toThrowError('Could not create predicate version "bogus" is not valid');
20
- });
21
- test('createVersionPredicate - throw api version coercion error', () => {
22
- const errorPredicate = () => createVersionPredicate('2', gte)('bogus');
23
- expect(errorPredicate).toThrowError('Version "bogus" is not valid and could not be coerced');
24
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { getAssetS3Path, isAsset, setAssetS3Path } from "../builtin-schema.js";
3
- test('getAssetS3Path', () => {
4
- expect(getAssetS3Path({
5
- _id: 'asset-id',
6
- _contentTypeId: 'ASSET',
7
- Hk6FQuz5: 'woo.jpg'
8
- })).toBe('woo.jpg');
9
- });
10
- test('setAssetS3Path', () => {
11
- const content = { _id: 'asset-id', _contentTypeId: 'ASSET' };
12
- setAssetS3Path(content, 'woo.jpg');
13
- expect(content.Hk6FQuz5).toBe('woo.jpg');
14
- });
15
- test('isAsset', () => {
16
- expect(isAsset({ _id: 'asset-id', _contentTypeId: 'ASSET', Hk6FQuz5: 'woo.jpg' })).toBe(true);
17
- expect(isAsset({ _id: 'asset-id', _contentTypeId: 'SITE' })).toBe(false);
18
- });
@@ -1 +0,0 @@
1
- export {};