@powerhousedao/reactor-api 6.0.0-dev.4 → 6.0.0-dev.40

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 (155) hide show
  1. package/dist/codegen.js +1 -1
  2. package/dist/codegen.js.map +1 -1
  3. package/dist/src/config.d.ts +1 -2
  4. package/dist/src/config.d.ts.map +1 -1
  5. package/dist/src/config.js +1 -5
  6. package/dist/src/config.js.map +1 -1
  7. package/dist/src/graphql/auth/subgraph.js +1 -1
  8. package/dist/src/graphql/auth/subgraph.js.map +1 -1
  9. package/dist/src/graphql/base-subgraph.d.ts +2 -2
  10. package/dist/src/graphql/base-subgraph.d.ts.map +1 -1
  11. package/dist/src/graphql/base-subgraph.js.map +1 -1
  12. package/dist/src/graphql/document-model-subgraph.d.ts +95 -43
  13. package/dist/src/graphql/document-model-subgraph.d.ts.map +1 -1
  14. package/dist/src/graphql/document-model-subgraph.js +570 -79
  15. package/dist/src/graphql/document-model-subgraph.js.map +1 -1
  16. package/dist/src/graphql/drive-subgraph.d.ts.map +1 -1
  17. package/dist/src/graphql/drive-subgraph.js +1 -0
  18. package/dist/src/graphql/drive-subgraph.js.map +1 -1
  19. package/dist/src/graphql/graphql-manager.d.ts +7 -2
  20. package/dist/src/graphql/graphql-manager.d.ts.map +1 -1
  21. package/dist/src/graphql/graphql-manager.js +128 -42
  22. package/dist/src/graphql/graphql-manager.js.map +1 -1
  23. package/dist/src/graphql/index.d.ts +1 -0
  24. package/dist/src/graphql/index.d.ts.map +1 -1
  25. package/dist/src/graphql/index.js +1 -0
  26. package/dist/src/graphql/index.js.map +1 -1
  27. package/dist/src/graphql/reactor/adapters.d.ts +10 -2
  28. package/dist/src/graphql/reactor/adapters.d.ts.map +1 -1
  29. package/dist/src/graphql/reactor/adapters.js +35 -1
  30. package/dist/src/graphql/reactor/adapters.js.map +1 -1
  31. package/dist/src/graphql/reactor/factory.d.ts +1 -1
  32. package/dist/src/graphql/reactor/factory.d.ts.map +1 -1
  33. package/dist/src/graphql/reactor/factory.js +1 -1
  34. package/dist/src/graphql/reactor/factory.js.map +1 -1
  35. package/dist/src/graphql/reactor/gen/graphql.d.ts +84 -24
  36. package/dist/src/graphql/reactor/gen/graphql.d.ts.map +1 -1
  37. package/dist/src/graphql/reactor/gen/graphql.js +33 -9
  38. package/dist/src/graphql/reactor/gen/graphql.js.map +1 -1
  39. package/dist/src/graphql/reactor/index.d.ts +1 -1
  40. package/dist/src/graphql/reactor/index.d.ts.map +1 -1
  41. package/dist/src/graphql/reactor/index.js +1 -1
  42. package/dist/src/graphql/reactor/index.js.map +1 -1
  43. package/dist/src/graphql/reactor/requester.with-zod.d.ts.map +1 -1
  44. package/dist/src/graphql/reactor/requester.with-zod.js +100 -38
  45. package/dist/src/graphql/reactor/requester.with-zod.js.map +1 -1
  46. package/dist/src/graphql/reactor/resolvers.d.ts +41 -21
  47. package/dist/src/graphql/reactor/resolvers.d.ts.map +1 -1
  48. package/dist/src/graphql/reactor/resolvers.js +118 -64
  49. package/dist/src/graphql/reactor/resolvers.js.map +1 -1
  50. package/dist/src/graphql/reactor/schema.graphql +51 -31
  51. package/dist/src/graphql/reactor/subgraph.d.ts.map +1 -1
  52. package/dist/src/graphql/reactor/subgraph.js +91 -108
  53. package/dist/src/graphql/reactor/subgraph.js.map +1 -1
  54. package/dist/src/graphql/reactor/validation.d.ts +24 -0
  55. package/dist/src/graphql/reactor/validation.d.ts.map +1 -1
  56. package/dist/src/graphql/reactor/validation.js +15 -0
  57. package/dist/src/graphql/reactor/validation.js.map +1 -1
  58. package/dist/src/graphql/system/index.d.ts +0 -1
  59. package/dist/src/graphql/system/index.d.ts.map +1 -1
  60. package/dist/src/graphql/system/index.js +0 -1
  61. package/dist/src/graphql/system/index.js.map +1 -1
  62. package/dist/src/graphql/types.d.ts +3 -3
  63. package/dist/src/graphql/types.d.ts.map +1 -1
  64. package/dist/src/graphql/utils.d.ts.map +1 -1
  65. package/dist/src/graphql/utils.js +7 -3
  66. package/dist/src/graphql/utils.js.map +1 -1
  67. package/dist/src/packages/import-loader.d.ts +5 -3
  68. package/dist/src/packages/import-loader.d.ts.map +1 -1
  69. package/dist/src/packages/import-loader.js +19 -10
  70. package/dist/src/packages/import-loader.js.map +1 -1
  71. package/dist/src/packages/package-manager.d.ts +2 -2
  72. package/dist/src/packages/package-manager.d.ts.map +1 -1
  73. package/dist/src/packages/package-manager.js.map +1 -1
  74. package/dist/src/packages/types.d.ts +8 -4
  75. package/dist/src/packages/types.d.ts.map +1 -1
  76. package/dist/src/packages/util.d.ts +3 -2
  77. package/dist/src/packages/util.d.ts.map +1 -1
  78. package/dist/src/packages/util.js +1 -1
  79. package/dist/src/packages/util.js.map +1 -1
  80. package/dist/src/packages/vite-loader.d.ts +7 -6
  81. package/dist/src/packages/vite-loader.d.ts.map +1 -1
  82. package/dist/src/packages/vite-loader.js +21 -8
  83. package/dist/src/packages/vite-loader.js.map +1 -1
  84. package/dist/src/server.d.ts +16 -7
  85. package/dist/src/server.d.ts.map +1 -1
  86. package/dist/src/server.js +117 -59
  87. package/dist/src/server.js.map +1 -1
  88. package/dist/src/services/auth.service.d.ts.map +1 -1
  89. package/dist/src/services/auth.service.js +11 -20
  90. package/dist/src/services/auth.service.js.map +1 -1
  91. package/dist/src/tracing.js +1 -1
  92. package/dist/src/tracing.js.map +1 -1
  93. package/dist/src/types.d.ts +5 -5
  94. package/dist/src/types.d.ts.map +1 -1
  95. package/dist/src/utils/create-schema.d.ts +21 -1
  96. package/dist/src/utils/create-schema.d.ts.map +1 -1
  97. package/dist/src/utils/create-schema.js +290 -16
  98. package/dist/src/utils/create-schema.js.map +1 -1
  99. package/dist/src/utils/drive-url.d.ts +2 -0
  100. package/dist/src/utils/drive-url.d.ts.map +1 -0
  101. package/dist/src/utils/drive-url.js +3 -0
  102. package/dist/src/utils/drive-url.js.map +1 -0
  103. package/dist/src/utils/index.d.ts +1 -0
  104. package/dist/src/utils/index.d.ts.map +1 -1
  105. package/dist/src/utils/index.js +1 -0
  106. package/dist/src/utils/index.js.map +1 -1
  107. package/dist/test/document-drive-subgraph.test.d.ts +2 -0
  108. package/dist/test/document-drive-subgraph.test.d.ts.map +1 -0
  109. package/dist/test/document-drive-subgraph.test.js +186 -0
  110. package/dist/test/document-drive-subgraph.test.js.map +1 -0
  111. package/dist/test/document-model-subgraph-legacy-permissions.test.d.ts +2 -0
  112. package/dist/test/document-model-subgraph-legacy-permissions.test.d.ts.map +1 -0
  113. package/dist/test/document-model-subgraph-legacy-permissions.test.js +518 -0
  114. package/dist/test/document-model-subgraph-legacy-permissions.test.js.map +1 -0
  115. package/dist/test/document-model-subgraph-permissions.test.d.ts +2 -0
  116. package/dist/test/document-model-subgraph-permissions.test.d.ts.map +1 -0
  117. package/dist/test/document-model-subgraph-permissions.test.js +635 -0
  118. package/dist/test/document-model-subgraph-permissions.test.js.map +1 -0
  119. package/dist/test/document-model-subgraph.test.d.ts +2 -0
  120. package/dist/test/document-model-subgraph.test.d.ts.map +1 -0
  121. package/dist/test/document-model-subgraph.test.js +441 -0
  122. package/dist/test/document-model-subgraph.test.js.map +1 -0
  123. package/dist/test/permissions-integration.test.js +4 -4
  124. package/dist/test/permissions-integration.test.js.map +1 -1
  125. package/dist/test/reactor-client.test.js +4 -4
  126. package/dist/test/reactor-client.test.js.map +1 -1
  127. package/dist/test/reactor-resolvers.test.js +4 -8
  128. package/dist/test/reactor-resolvers.test.js.map +1 -1
  129. package/dist/test/reactor-subgraph-permissions.test.js +4 -7
  130. package/dist/test/reactor-subgraph-permissions.test.js.map +1 -1
  131. package/dist/test/subscriptions.test.js +2 -0
  132. package/dist/test/subscriptions.test.js.map +1 -1
  133. package/dist/test/two-reactor-gql-catchup-duplicate.test.d.ts +2 -0
  134. package/dist/test/two-reactor-gql-catchup-duplicate.test.d.ts.map +1 -0
  135. package/dist/test/two-reactor-gql-catchup-duplicate.test.js +264 -0
  136. package/dist/test/two-reactor-gql-catchup-duplicate.test.js.map +1 -0
  137. package/dist/test/two-reactor-gql-sync.test.js +86 -99
  138. package/dist/test/two-reactor-gql-sync.test.js.map +1 -1
  139. package/dist/test/utils/gql-resolver-bridge.d.ts.map +1 -1
  140. package/dist/test/utils/gql-resolver-bridge.js +4 -4
  141. package/dist/test/utils/gql-resolver-bridge.js.map +1 -1
  142. package/dist/tsconfig.tsbuildinfo +1 -1
  143. package/package.json +21 -11
  144. package/dist/src/graphql/system/system-subgraph.d.ts +0 -49
  145. package/dist/src/graphql/system/system-subgraph.d.ts.map +0 -1
  146. package/dist/src/graphql/system/system-subgraph.js +0 -130
  147. package/dist/src/graphql/system/system-subgraph.js.map +0 -1
  148. package/dist/test/system.test.d.ts +0 -2
  149. package/dist/test/system.test.d.ts.map +0 -1
  150. package/dist/test/system.test.js +0 -211
  151. package/dist/test/system.test.js.map +0 -1
  152. package/dist/test/three-reactor-gql-sync.test.d.ts +0 -2
  153. package/dist/test/three-reactor-gql-sync.test.d.ts.map +0 -1
  154. package/dist/test/three-reactor-gql-sync.test.js +0 -368
  155. package/dist/test/three-reactor-gql-sync.test.js.map +0 -1
@@ -6,6 +6,16 @@ import { Kind, print } from "graphql";
6
6
  import { gql } from "graphql-tag";
7
7
  import { GraphQLJSONObject } from "graphql-type-json";
8
8
  const logger = childLogger(["reactor-api", "create-schema"]);
9
+ /**
10
+ * Revision type - matches the definition in reactor/schema.graphql.
11
+ * Used by PHDocument and document mutation results.
12
+ */
13
+ const RevisionType = `
14
+ type Revision {
15
+ scope: String!
16
+ revision: Int!
17
+ }
18
+ `;
9
19
  /**
10
20
  * Strip scalar definitions from a DocumentNode to avoid duplicates
11
21
  * when combining with other schemas that define the same scalars.
@@ -58,12 +68,13 @@ export const getDocumentModelTypeDefs = (documentDriveServer, typeDefs) => {
58
68
  .join("\n")};
59
69
 
60
70
  \n`;
61
- const found = tmpDmSchema.match(/(type|enum|union|interface)\s+(\w+)\s/g);
71
+ const found = tmpDmSchema.match(/(type|enum|union|interface)\s+(\w+)[\s{]/g);
62
72
  const trimmedFound = found?.map((f) => f
63
73
  .replaceAll("type ", "")
64
74
  .replaceAll("enum ", "")
65
75
  .replaceAll("union ", "")
66
76
  .replaceAll("interface ", "")
77
+ .replaceAll("{", "")
67
78
  .trim());
68
79
  trimmedFound?.forEach((f) => {
69
80
  // Create a regex that matches the type name with proper boundaries
@@ -181,7 +192,7 @@ export const getDocumentModelTypeDefs = (documentDriveServer, typeDefs) => {
181
192
  * @returns {string[]} Array of type names
182
193
  */
183
194
  function extractTypeNames(schema) {
184
- const found = schema.match(/(type|enum|union|interface|input)\s+(\w+)\s/g);
195
+ const found = schema.match(/(type|enum|union|interface|input)\s+(\w+)[\s{]/g);
185
196
  if (!found)
186
197
  return [];
187
198
  return found.map((f) => f
@@ -190,8 +201,31 @@ function extractTypeNames(schema) {
190
201
  .replaceAll("union ", "")
191
202
  .replaceAll("interface ", "")
192
203
  .replaceAll("input ", "")
204
+ .replaceAll("{", "")
193
205
  .trim());
194
206
  }
207
+ /**
208
+ * Extract input type definitions from a GraphQL schema.
209
+ * @param {string} schema - GraphQL schema string
210
+ * @param {Set<string>} excludeTypeNames - Type names to exclude from extraction
211
+ * @returns {string} All input type definitions as a string
212
+ */
213
+ function extractInputTypeDefinitions(schema, excludeTypeNames = new Set()) {
214
+ // Match input type blocks: input TypeName { ... }
215
+ const inputTypeRegex = /input\s+(\w+)\s*\{[^}]*\}/g;
216
+ const matches = [];
217
+ let match;
218
+ while ((match = inputTypeRegex.exec(schema)) !== null) {
219
+ const typeName = match[1];
220
+ // Skip if this type name is in the exclusion set
221
+ if (!excludeTypeNames.has(typeName)) {
222
+ matches.push(match[0]);
223
+ }
224
+ }
225
+ if (matches.length === 0)
226
+ return "";
227
+ return matches.join("\n\n");
228
+ }
195
229
  /**
196
230
  * Apply type prefixes to GraphQL schema to namespace types and avoid collisions.
197
231
  * Inlined from @powerhousedao/common/utils to avoid ES module import issues.
@@ -230,11 +264,69 @@ function applyGraphQLTypePrefixes(schema, prefix, externalTypeNames = []) {
230
264
  });
231
265
  return processedSchema;
232
266
  }
233
- export function generateDocumentModelSchemaLegacy(documentModel) {
267
+ /**
268
+ * Generate a GraphQL schema for a document model.
269
+ *
270
+ * @param documentModel - The document model global state
271
+ * @param options - Schema generation options
272
+ * @returns GraphQL DocumentNode
273
+ */
274
+ export function generateDocumentModelSchema(documentModel, options = {}) {
275
+ const { useNewApi = false } = options;
234
276
  const specification = documentModel.specifications.at(-1);
235
277
  const documentName = getDocumentModelSchemaName(documentModel);
236
- const stateSchema = specification?.state.global.schema;
237
- const stateTypeNames = extractTypeNames(stateSchema ?? "");
278
+ const globalStateSchema = specification?.state.global.schema;
279
+ const localStateSchema = specification?.state.local.schema;
280
+ const globalStateTypeNames = extractTypeNames(globalStateSchema ?? "");
281
+ const localStateTypeNames = extractTypeNames(localStateSchema ?? "");
282
+ const stateTypeNames = [...globalStateTypeNames, ...localStateTypeNames];
283
+ // Collect ALL type names from all operations' schemas
284
+ const allOperationTypeNames = specification?.modules.flatMap((module) => module.operations.flatMap((op) => extractTypeNames(op.schema ?? ""))) ?? [];
285
+ // Combine state types and all operation types for prefixing
286
+ const allTypeNames = [
287
+ ...new Set([...stateTypeNames, ...allOperationTypeNames]),
288
+ ];
289
+ // Extract input type definitions from state schema, excluding operation-specific inputs
290
+ // (those are already defined in op.schema)
291
+ const operationInputTypeNames = new Set(allOperationTypeNames);
292
+ const stateInputTypes = extractInputTypeDefinitions(globalStateSchema ?? "", operationInputTypeNames);
293
+ const prefixedStateInputTypes = applyGraphQLTypePrefixes(stateInputTypes, documentName, allTypeNames);
294
+ // Helper to check if schema has actual GraphQL type definitions
295
+ const hasValidSchema = (schema) => !!(schema && /\b(input|type|enum|union|interface)\s+\w+/.test(schema));
296
+ // Process state schema types (remove input types, clean up, and prefix)
297
+ const stateSchemaTypes = globalStateSchema
298
+ ? applyGraphQLTypePrefixes(globalStateSchema
299
+ .replaceAll("scalar DateTime", "")
300
+ .replaceAll(/input (.*?) {[\s\S]*?}/g, ""), documentName, allTypeNames)
301
+ : "";
302
+ if (useNewApi) {
303
+ // New API: flat queries, typed state, async mutations
304
+ return generateNewApiSchema(documentName, specification, stateSchemaTypes, prefixedStateInputTypes, allTypeNames, hasValidSchema);
305
+ }
306
+ // Legacy API
307
+ return generateLegacyApiSchema(documentName, specification, prefixedStateInputTypes, allTypeNames, hasValidSchema);
308
+ }
309
+ /**
310
+ * Generate legacy API schema with nested queries
311
+ */
312
+ function generateLegacyApiSchema(documentName, specification, prefixedStateInputTypes, allTypeNames, hasValidSchema) {
313
+ const createDocumentMutation = `${documentName}_createDocument(name:String!, driveId:String): String`;
314
+ const operationMutations = specification?.modules
315
+ .flatMap((module) => module.operations
316
+ .filter((op) => op.name && hasValidSchema(op.schema))
317
+ .map((op) => `${documentName}_${camelCase(op.name)}(
318
+ driveId: String, docId: PHID, input: ${documentName}_${pascalCase(op.name)}Input): Int`))
319
+ .join("\n ") ?? "";
320
+ const moduleSchemas = specification?.modules
321
+ .filter((module) => module.operations.some((op) => hasValidSchema(op.schema)))
322
+ .map((module) => `"""
323
+ Module: ${pascalCase(module.name)}
324
+ """
325
+ ${module.operations
326
+ .filter((op) => hasValidSchema(op.schema))
327
+ .map((op) => applyGraphQLTypePrefixes(op.schema ?? "", documentName, allTypeNames))
328
+ .join("\n ")}`)
329
+ .join("\n") ?? "";
238
330
  return gql `
239
331
  """
240
332
  Queries: ${documentName} Document
@@ -253,23 +345,205 @@ export function generateDocumentModelSchemaLegacy(documentModel) {
253
345
  Mutations: ${documentName}
254
346
  """
255
347
  type Mutation {
256
- ${documentName}_createDocument(name:String!, driveId:String): String
348
+ ${createDocumentMutation}
257
349
 
258
- ${specification?.modules
259
- .flatMap((module) => module.operations
260
- .filter((op) => op.name)
261
- .map((op) => `${documentName}_${camelCase(op.name)}(
262
- driveId: String, docId: PHID, input: ${documentName}_${pascalCase(op.name)}Input): Int`))
263
- .join("\n ") ?? ""}
350
+ ${operationMutations}
351
+ }
352
+
353
+ ${prefixedStateInputTypes
354
+ ? `"""
355
+ Input Types from State Schema
356
+ """
357
+ ${prefixedStateInputTypes}`
358
+ : ""}
359
+
360
+ ${moduleSchemas}`;
361
+ }
362
+ /**
363
+ * Generate new API schema with flat queries, typed state, and async mutations.
364
+ * Note: State schema types are NOT included here because they are already defined
365
+ * in getDocumentModelTypeDefs() which is used during schema composition.
366
+ * Including them here would cause duplicate type definitions.
367
+ *
368
+ * Special case: DocumentModel type doesn't have a typed state defined in
369
+ * getDocumentModelTypeDefs(), so we use JSONObject for its state field.
370
+ */
371
+ function generateNewApiSchema(documentName, specification, _stateSchemaTypes, prefixedStateInputTypes, allTypeNames, hasValidSchema) {
372
+ // Use full state type for all document models
373
+ const stateType = `${documentName}_FullState!`;
374
+ // Shared base types for document state structure (same for all document types)
375
+ const sharedBaseTypes = `
376
+ """Hash configuration for document state"""
377
+ type ${documentName}_PHHashConfig {
378
+ algorithm: String!
379
+ encoding: String!
380
+ }
381
+
382
+ """Document scope state (same for all document types)"""
383
+ type ${documentName}_PHDocumentScopeState {
384
+ version: Int!
385
+ hash: ${documentName}_PHHashConfig!
386
+ isDeleted: Boolean
387
+ deletedAtUtcIso: String
388
+ deletedBy: String
389
+ deletionReason: String
390
+ }
391
+ `;
392
+ // Full state type with all scopes (auth, document, global, local)
393
+ // Note: DocumentModel uses different naming convention (GlobalState suffix instead of State)
394
+ // For local state, check if the specification defines a local state type
395
+ const localSchema = specification?.state.local.schema ?? "";
396
+ const hasLocalStateType = localSchema.includes(`type ${documentName}LocalState`);
397
+ const globalStateType = documentName === "DocumentModel"
398
+ ? `${documentName}_${documentName}GlobalState!`
399
+ : `${documentName}_${documentName}State!`;
400
+ const localStateType = !hasLocalStateType
401
+ ? "JSONObject!"
402
+ : `${documentName}_${documentName}LocalState!`;
403
+ const fullStateType = `
404
+ """Full state with all scopes for ${documentName}"""
405
+ type ${documentName}_FullState {
406
+ auth: JSONObject!
407
+ document: ${documentName}_PHDocumentScopeState!
408
+ global: ${globalStateType}
409
+ local: ${localStateType}
264
410
  }
265
-
266
- ${specification?.modules
411
+ `;
412
+ // Common input types - use extend to avoid conflicts with other subgraphs
413
+ const commonInputTypes = `
414
+ input ${documentName}_ViewFilterInput {
415
+ branch: String
416
+ scopes: [String!]
417
+ }
418
+
419
+ input ${documentName}_PagingInput {
420
+ limit: Int
421
+ offset: Int
422
+ cursor: String
423
+ }
424
+
425
+ input ${documentName}_SearchFilterInput {
426
+ parentId: String
427
+ identifiers: [String!]
428
+ }
429
+ `;
430
+ // Revision type - imported from shared-schema.ts for consistency with ReactorSubgraph
431
+ // Must be defined in each subgraph for Apollo Federation
432
+ const revisionType = RevisionType;
433
+ // Result types with typed state (or JSONObject for DocumentModel)
434
+ // The state type (${documentName}_${documentName}State) is defined in getDocumentModelTypeDefs()
435
+ // Uses revisionsList with shared Revision type to match ReactorSubgraph pattern
436
+ const resultTypes = `
437
+ """
438
+ Mutation result type for ${documentName} operations with typed state.
439
+ Matches ReactorSubgraph PHDocument pattern with revisionsList.
440
+ """
441
+ type ${documentName}MutationResult {
442
+ id: String!
443
+ slug: String
444
+ name: String!
445
+ documentType: String!
446
+ state: ${stateType}
447
+ revisionsList: [Revision!]!
448
+ createdAtUtcIso: DateTime!
449
+ lastModifiedAtUtcIso: DateTime!
450
+ parentId: String
451
+ }
452
+
453
+ """
454
+ Document with children for ${documentName}
455
+ """
456
+ type ${documentName}_DocumentWithChildren {
457
+ document: ${documentName}MutationResult!
458
+ childIds: [String!]!
459
+ }
460
+
461
+ """
462
+ Paginated result type for ${documentName} documents
463
+ """
464
+ type ${documentName}_DocumentResultPage {
465
+ items: [${documentName}MutationResult!]!
466
+ totalCount: Int!
467
+ hasNextPage: Boolean!
468
+ hasPreviousPage: Boolean!
469
+ cursor: String
470
+ }
471
+ `;
472
+ // Flat queries (not nested) - prefixed input types to avoid conflicts
473
+ const queries = `
474
+ type Query {
475
+ """Get a specific ${documentName} document by identifier"""
476
+ ${documentName}_document(identifier: String!, view: ${documentName}_ViewFilterInput): ${documentName}_DocumentWithChildren
477
+
478
+ """Find ${documentName} documents by search criteria"""
479
+ ${documentName}_findDocuments(search: ${documentName}_SearchFilterInput!, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
480
+
481
+ """Get children of a ${documentName} document"""
482
+ ${documentName}_documentChildren(parentIdentifier: String!, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
483
+
484
+ """Get parents of a ${documentName} document"""
485
+ ${documentName}_documentParents(childIdentifier: String!, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
486
+ }
487
+ `;
488
+ // Mutations: sync and async versions
489
+ const createDocumentMutation = `${documentName}_createDocument(name: String!, parentIdentifier: String): ${documentName}MutationResult!`;
490
+ const createEmptyDocumentMutation = `${documentName}_createEmptyDocument(parentIdentifier: String): ${documentName}MutationResult!`;
491
+ const operationMutations = specification?.modules
492
+ .flatMap((module) => module.operations
493
+ .filter((op) => op.name && hasValidSchema(op.schema))
494
+ .flatMap((op) => [
495
+ // Sync mutation
496
+ `${documentName}_${camelCase(op.name)}(docId: PHID!, input: ${documentName}_${pascalCase(op.name)}Input!): ${documentName}MutationResult!`,
497
+ // Async mutation
498
+ `${documentName}_${camelCase(op.name)}Async(docId: PHID!, input: ${documentName}_${pascalCase(op.name)}Input!): String!`,
499
+ ]))
500
+ .join("\n ") ?? "";
501
+ const moduleSchemas = specification?.modules
502
+ .filter((module) => module.operations.some((op) => hasValidSchema(op.schema)))
267
503
  .map((module) => `"""
268
504
  Module: ${pascalCase(module.name)}
269
505
  """
270
506
  ${module.operations
271
- .map((op) => applyGraphQLTypePrefixes(op.schema ?? "", documentName, stateTypeNames))
507
+ .filter((op) => hasValidSchema(op.schema))
508
+ .map((op) => applyGraphQLTypePrefixes(op.schema ?? "", documentName, allTypeNames))
272
509
  .join("\n ")}`)
273
- .join("\n") ?? ""}`;
510
+ .join("\n") ?? "";
511
+ return gql `
512
+ scalar DateTime
513
+ scalar JSONObject
514
+
515
+ ${revisionType}
516
+
517
+ ${sharedBaseTypes}
518
+
519
+ ${fullStateType}
520
+
521
+ ${commonInputTypes}
522
+
523
+ ${resultTypes}
524
+
525
+ """
526
+ Queries: ${documentName} Document
527
+ """
528
+ ${queries}
529
+
530
+ """
531
+ Mutations: ${documentName}
532
+ """
533
+ type Mutation {
534
+ ${createDocumentMutation}
535
+ ${createEmptyDocumentMutation}
536
+
537
+ ${operationMutations}
538
+ }
539
+
540
+ ${prefixedStateInputTypes
541
+ ? `"""
542
+ Input Types from State Schema
543
+ """
544
+ ${prefixedStateInputTypes}`
545
+ : ""}
546
+
547
+ ${moduleSchemas}`;
274
548
  }
275
549
  //# sourceMappingURL=create-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-schema.js","sourceRoot":"","sources":["../../../src/utils/create-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE1F,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAA6B,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAqB,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAAC,GAAiB,EAAU,EAAE;IAC3D,MAAM,mBAAmB,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,sBA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E,CAAC;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { driveIdFromUrl, parseDriveUrl, type ParsedDriveUrl, } from "@powerhousedao/reactor";
2
+ //# sourceMappingURL=drive-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drive-url.d.ts","sourceRoot":"","sources":["../../../src/utils/drive-url.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Re-export from @powerhousedao/reactor for backwards compatibility
2
+ export { driveIdFromUrl, parseDriveUrl, } from "@powerhousedao/reactor";
3
+ //# sourceMappingURL=drive-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drive-url.js","sourceRoot":"","sources":["../../../src/utils/drive-url.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,EACL,cAAc,EACd,aAAa,GAEd,MAAM,wBAAwB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./create-schema.js";
2
2
  export * from "./db.js";
3
+ export * from "./drive-url.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./create-schema.js";
2
2
  export * from "./db.js";
3
+ export * from "./drive-url.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=document-drive-subgraph.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-drive-subgraph.test.d.ts","sourceRoot":"","sources":["../../test/document-drive-subgraph.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,186 @@
1
+ import { testSetupReactor } from "@powerhousedao/reactor-api/test";
2
+ import { driveDocumentModelModule } from "document-drive";
3
+ import { print } from "graphql";
4
+ import { beforeEach, describe, expect, it } from "vitest";
5
+ import { DocumentModelSubgraph } from "../src/graphql/document-model-subgraph.js";
6
+ import { generateDocumentModelSchema, getDocumentModelSchemaName, } from "../src/utils/create-schema.js";
7
+ /**
8
+ * Tests for document-drive subgraph auto-generation via DocumentModelSubgraph.
9
+ *
10
+ * Verifies that the new DocumentModelSubgraph produces valid schemas, resolvers,
11
+ * and union type resolvers for the document-drive document model.
12
+ */
13
+ describe("Document-Drive Subgraph", () => {
14
+ const driveModule = driveDocumentModelModule;
15
+ const documentName = getDocumentModelSchemaName(driveModule.documentModel.global);
16
+ describe("schema generation", () => {
17
+ it("should generate a valid schema for document-drive", () => {
18
+ expect(() => generateDocumentModelSchema(driveModule.documentModel.global, {
19
+ useNewApi: true,
20
+ })).not.toThrow();
21
+ });
22
+ it("should include mutations for valid operations", () => {
23
+ const schema = generateDocumentModelSchema(driveModule.documentModel.global, { useNewApi: true });
24
+ const printed = print(schema);
25
+ // Node operations
26
+ expect(printed).toContain(`${documentName}_addFile`);
27
+ expect(printed).toContain(`${documentName}_addFolder`);
28
+ expect(printed).toContain(`${documentName}_deleteNode`);
29
+ expect(printed).toContain(`${documentName}_updateFile`);
30
+ expect(printed).toContain(`${documentName}_updateNode`);
31
+ expect(printed).toContain(`${documentName}_copyNode`);
32
+ expect(printed).toContain(`${documentName}_moveNode`);
33
+ // Drive operations
34
+ expect(printed).toContain(`${documentName}_setDriveName`);
35
+ expect(printed).toContain(`${documentName}_setDriveIcon`);
36
+ expect(printed).toContain(`${documentName}_setSharingType`);
37
+ expect(printed).toContain(`${documentName}_setAvailableOffline`);
38
+ // Cleanup operations
39
+ expect(printed).toContain(`${documentName}_removeListener`);
40
+ expect(printed).toContain(`${documentName}_removeTrigger`);
41
+ });
42
+ it("should include listener and trigger operations", () => {
43
+ const schema = generateDocumentModelSchema(driveModule.documentModel.global, { useNewApi: true });
44
+ const printed = print(schema);
45
+ // ADD_LISTENER and ADD_TRIGGER now have proper input types and should be included
46
+ expect(printed).toContain(`${documentName}_addListener(`);
47
+ expect(printed).toContain(`${documentName}_addTrigger(`);
48
+ expect(printed).toContain(`${documentName}_addListenerAsync(`);
49
+ expect(printed).toContain(`${documentName}_addTriggerAsync(`);
50
+ });
51
+ it("should include query types", () => {
52
+ const schema = generateDocumentModelSchema(driveModule.documentModel.global, { useNewApi: true });
53
+ const printed = print(schema);
54
+ expect(printed).toContain(`${documentName}_document`);
55
+ expect(printed).toContain(`${documentName}_findDocuments`);
56
+ expect(printed).toContain(`${documentName}_documentChildren`);
57
+ expect(printed).toContain(`${documentName}_documentParents`);
58
+ });
59
+ it("should include async mutation variants", () => {
60
+ const schema = generateDocumentModelSchema(driveModule.documentModel.global, { useNewApi: true });
61
+ const printed = print(schema);
62
+ expect(printed).toContain(`${documentName}_addFileAsync`);
63
+ expect(printed).toContain(`${documentName}_deleteNodeAsync`);
64
+ expect(printed).toContain(`${documentName}_setDriveNameAsync`);
65
+ });
66
+ });
67
+ describe("DocumentModelSubgraph resolver generation", () => {
68
+ let reactor;
69
+ let subgraph;
70
+ beforeEach(async () => {
71
+ const setup = await testSetupReactor();
72
+ reactor = setup.reactor;
73
+ subgraph = new DocumentModelSubgraph(driveModule, {
74
+ reactor,
75
+ reactorClient: undefined,
76
+ documentPermissionService: undefined,
77
+ relationalDb: {},
78
+ graphqlManager: {},
79
+ syncManager: {},
80
+ analyticsStore: {},
81
+ });
82
+ });
83
+ it("should generate mutation resolvers for valid operations (sync + async)", () => {
84
+ const mutations = subgraph.resolvers.Mutation;
85
+ // Node operations - sync
86
+ expect(mutations[`${documentName}_addFile`]).toBeTypeOf("function");
87
+ expect(mutations[`${documentName}_addFolder`]).toBeTypeOf("function");
88
+ expect(mutations[`${documentName}_deleteNode`]).toBeTypeOf("function");
89
+ expect(mutations[`${documentName}_updateFile`]).toBeTypeOf("function");
90
+ expect(mutations[`${documentName}_updateNode`]).toBeTypeOf("function");
91
+ expect(mutations[`${documentName}_copyNode`]).toBeTypeOf("function");
92
+ expect(mutations[`${documentName}_moveNode`]).toBeTypeOf("function");
93
+ // Node operations - async
94
+ expect(mutations[`${documentName}_addFileAsync`]).toBeTypeOf("function");
95
+ expect(mutations[`${documentName}_deleteNodeAsync`]).toBeTypeOf("function");
96
+ // Drive operations - sync
97
+ expect(mutations[`${documentName}_setDriveName`]).toBeTypeOf("function");
98
+ expect(mutations[`${documentName}_setDriveIcon`]).toBeTypeOf("function");
99
+ expect(mutations[`${documentName}_setSharingType`]).toBeTypeOf("function");
100
+ expect(mutations[`${documentName}_setAvailableOffline`]).toBeTypeOf("function");
101
+ // Drive operations - async
102
+ expect(mutations[`${documentName}_setDriveNameAsync`]).toBeTypeOf("function");
103
+ // Cleanup operations
104
+ expect(mutations[`${documentName}_removeListener`]).toBeTypeOf("function");
105
+ expect(mutations[`${documentName}_removeTrigger`]).toBeTypeOf("function");
106
+ });
107
+ it("should generate mutation resolvers for listener and trigger operations", () => {
108
+ const mutations = subgraph.resolvers.Mutation;
109
+ // ADD_LISTENER and ADD_TRIGGER now have proper input types and should be included
110
+ expect(mutations[`${documentName}_addListener`]).toBeTypeOf("function");
111
+ expect(mutations[`${documentName}_addTrigger`]).toBeTypeOf("function");
112
+ expect(mutations[`${documentName}_addListenerAsync`]).toBeTypeOf("function");
113
+ expect(mutations[`${documentName}_addTriggerAsync`]).toBeTypeOf("function");
114
+ });
115
+ it("should generate flat query resolvers", () => {
116
+ const queries = subgraph.resolvers.Query;
117
+ expect(queries[`${documentName}_document`]).toBeTypeOf("function");
118
+ expect(queries[`${documentName}_findDocuments`]).toBeTypeOf("function");
119
+ expect(queries[`${documentName}_documentChildren`]).toBeTypeOf("function");
120
+ expect(queries[`${documentName}_documentParents`]).toBeTypeOf("function");
121
+ });
122
+ it("should generate createDocument and createEmptyDocument mutations", () => {
123
+ const mutations = subgraph.resolvers.Mutation;
124
+ expect(mutations[`${documentName}_createDocument`]).toBeTypeOf("function");
125
+ expect(mutations[`${documentName}_createEmptyDocument`]).toBeTypeOf("function");
126
+ });
127
+ });
128
+ describe("union type resolvers", () => {
129
+ let reactor;
130
+ let subgraph;
131
+ beforeEach(async () => {
132
+ const setup = await testSetupReactor();
133
+ reactor = setup.reactor;
134
+ subgraph = new DocumentModelSubgraph(driveModule, {
135
+ reactor,
136
+ reactorClient: undefined,
137
+ documentPermissionService: undefined,
138
+ relationalDb: {},
139
+ graphqlManager: {},
140
+ syncManager: {},
141
+ analyticsStore: {},
142
+ });
143
+ });
144
+ it("should generate a __resolveType resolver for DocumentDrive_Node", () => {
145
+ const nodeResolver = subgraph.resolvers[`${documentName}_Node`];
146
+ expect(nodeResolver).toBeDefined();
147
+ expect(nodeResolver.__resolveType).toBeTypeOf("function");
148
+ });
149
+ it("should resolve FileNode when object has documentType field", () => {
150
+ const nodeResolver = subgraph.resolvers[`${documentName}_Node`];
151
+ const fileNode = {
152
+ id: "file-1",
153
+ name: "test.txt",
154
+ kind: "file",
155
+ documentType: "powerhouse/document-model",
156
+ parentFolder: null,
157
+ };
158
+ expect(nodeResolver.__resolveType(fileNode)).toBe(`${documentName}_FileNode`);
159
+ });
160
+ it("should resolve FolderNode when object lacks documentType field", () => {
161
+ const nodeResolver = subgraph.resolvers[`${documentName}_Node`];
162
+ const folderNode = {
163
+ id: "folder-1",
164
+ name: "My Folder",
165
+ kind: "folder",
166
+ parentFolder: null,
167
+ };
168
+ expect(nodeResolver.__resolveType(folderNode)).toBe(`${documentName}_FolderNode`);
169
+ });
170
+ it("should generate a __resolveType resolver for DocumentDrive_TriggerData", () => {
171
+ const triggerDataResolver = subgraph.resolvers[`${documentName}_TriggerData`];
172
+ expect(triggerDataResolver).toBeDefined();
173
+ expect(triggerDataResolver.__resolveType).toBeTypeOf("function");
174
+ });
175
+ it("should resolve PullResponderTriggerData for TriggerData union", () => {
176
+ const triggerDataResolver = subgraph.resolvers[`${documentName}_TriggerData`];
177
+ const triggerData = {
178
+ listenerId: "listener-1",
179
+ url: "https://example.com",
180
+ interval: "30s",
181
+ };
182
+ expect(triggerDataResolver.__resolveType(triggerData)).toBe(`${documentName}_PullResponderTriggerData`);
183
+ });
184
+ });
185
+ });
186
+ //# sourceMappingURL=document-drive-subgraph.test.js.map