@powerhousedao/reactor-api 6.0.0-dev.153 → 6.0.0-dev.155
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/dist/index.d.mts +2948 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6353 -0
- package/dist/index.mjs.map +1 -0
- package/dist/src/packages/vite-loader.mjs +142 -0
- package/dist/src/packages/vite-loader.mjs.map +1 -0
- package/dist/types-Do4QTfT3.d.mts +37 -0
- package/dist/types-Do4QTfT3.d.mts.map +1 -0
- package/dist/utils-DEEhP99G.mjs +286 -0
- package/dist/utils-DEEhP99G.mjs.map +1 -0
- package/dist/vite-loader.d.mts +29 -0
- package/dist/vite-loader.d.mts.map +1 -0
- package/package.json +17 -25
- package/dist/codegen.d.ts +0 -4
- package/dist/codegen.d.ts.map +0 -1
- package/dist/codegen.js +0 -38
- package/dist/codegen.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/src/config.d.ts +0 -6
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js +0 -6
- package/dist/src/config.js.map +0 -1
- package/dist/src/dev.d.ts +0 -2
- package/dist/src/dev.d.ts.map +0 -1
- package/dist/src/dev.js +0 -51
- package/dist/src/dev.js.map +0 -1
- package/dist/src/graphql/analytics-subgraph.d.ts +0 -14
- package/dist/src/graphql/analytics-subgraph.d.ts.map +0 -1
- package/dist/src/graphql/analytics-subgraph.js +0 -26
- package/dist/src/graphql/analytics-subgraph.js.map +0 -1
- package/dist/src/graphql/auth/index.d.ts +0 -2
- package/dist/src/graphql/auth/index.d.ts.map +0 -1
- package/dist/src/graphql/auth/index.js +0 -2
- package/dist/src/graphql/auth/index.js.map +0 -1
- package/dist/src/graphql/auth/resolvers.d.ts +0 -166
- package/dist/src/graphql/auth/resolvers.d.ts.map +0 -1
- package/dist/src/graphql/auth/resolvers.js +0 -227
- package/dist/src/graphql/auth/resolvers.js.map +0 -1
- package/dist/src/graphql/auth/schema.graphql +0 -195
- package/dist/src/graphql/auth/subgraph.d.ts +0 -202
- package/dist/src/graphql/auth/subgraph.d.ts.map +0 -1
- package/dist/src/graphql/auth/subgraph.js +0 -384
- package/dist/src/graphql/auth/subgraph.js.map +0 -1
- package/dist/src/graphql/base-subgraph.d.ts +0 -27
- package/dist/src/graphql/base-subgraph.d.ts.map +0 -1
- package/dist/src/graphql/base-subgraph.js +0 -126
- package/dist/src/graphql/base-subgraph.js.map +0 -1
- package/dist/src/graphql/document-model-subgraph.d.ts +0 -110
- package/dist/src/graphql/document-model-subgraph.d.ts.map +0 -1
- package/dist/src/graphql/document-model-subgraph.js +0 -336
- package/dist/src/graphql/document-model-subgraph.js.map +0 -1
- package/dist/src/graphql/gateway/adapter-gateway-apollo.d.ts +0 -23
- package/dist/src/graphql/gateway/adapter-gateway-apollo.d.ts.map +0 -1
- package/dist/src/graphql/gateway/adapter-gateway-apollo.js +0 -156
- package/dist/src/graphql/gateway/adapter-gateway-apollo.js.map +0 -1
- package/dist/src/graphql/gateway/adapter-gateway-mercurius.d.ts +0 -17
- package/dist/src/graphql/gateway/adapter-gateway-mercurius.d.ts.map +0 -1
- package/dist/src/graphql/gateway/adapter-gateway-mercurius.js +0 -154
- package/dist/src/graphql/gateway/adapter-gateway-mercurius.js.map +0 -1
- package/dist/src/graphql/gateway/adapter-http-express.d.ts +0 -25
- package/dist/src/graphql/gateway/adapter-http-express.d.ts.map +0 -1
- package/dist/src/graphql/gateway/adapter-http-express.js +0 -163
- package/dist/src/graphql/gateway/adapter-http-express.js.map +0 -1
- package/dist/src/graphql/gateway/adapter-http-fastify.d.ts +0 -23
- package/dist/src/graphql/gateway/adapter-http-fastify.d.ts.map +0 -1
- package/dist/src/graphql/gateway/adapter-http-fastify.js +0 -228
- package/dist/src/graphql/gateway/adapter-http-fastify.js.map +0 -1
- package/dist/src/graphql/gateway/auth-middleware.d.ts +0 -7
- package/dist/src/graphql/gateway/auth-middleware.d.ts.map +0 -1
- package/dist/src/graphql/gateway/auth-middleware.js +0 -15
- package/dist/src/graphql/gateway/auth-middleware.js.map +0 -1
- package/dist/src/graphql/gateway/factory.d.ts +0 -11
- package/dist/src/graphql/gateway/factory.d.ts.map +0 -1
- package/dist/src/graphql/gateway/factory.js +0 -21
- package/dist/src/graphql/gateway/factory.js.map +0 -1
- package/dist/src/graphql/gateway/types.d.ts +0 -100
- package/dist/src/graphql/gateway/types.d.ts.map +0 -1
- package/dist/src/graphql/gateway/types.js +0 -2
- package/dist/src/graphql/gateway/types.js.map +0 -1
- package/dist/src/graphql/graphql-manager.d.ts +0 -65
- package/dist/src/graphql/graphql-manager.d.ts.map +0 -1
- package/dist/src/graphql/graphql-manager.js +0 -483
- package/dist/src/graphql/graphql-manager.js.map +0 -1
- package/dist/src/graphql/index.d.ts +0 -13
- package/dist/src/graphql/index.d.ts.map +0 -1
- package/dist/src/graphql/index.js +0 -13
- package/dist/src/graphql/index.js.map +0 -1
- package/dist/src/graphql/packages/index.d.ts +0 -2
- package/dist/src/graphql/packages/index.d.ts.map +0 -1
- package/dist/src/graphql/packages/index.js +0 -2
- package/dist/src/graphql/packages/index.js.map +0 -1
- package/dist/src/graphql/packages/resolvers.d.ts +0 -31
- package/dist/src/graphql/packages/resolvers.d.ts.map +0 -1
- package/dist/src/graphql/packages/resolvers.js +0 -37
- package/dist/src/graphql/packages/resolvers.js.map +0 -1
- package/dist/src/graphql/packages/schema.graphql +0 -50
- package/dist/src/graphql/packages/subgraph.d.ts +0 -55
- package/dist/src/graphql/packages/subgraph.d.ts.map +0 -1
- package/dist/src/graphql/packages/subgraph.js +0 -73
- package/dist/src/graphql/packages/subgraph.js.map +0 -1
- package/dist/src/graphql/playground.d.ts +0 -2
- package/dist/src/graphql/playground.d.ts.map +0 -1
- package/dist/src/graphql/playground.js +0 -81
- package/dist/src/graphql/playground.js.map +0 -1
- package/dist/src/graphql/reactor/adapters.d.ts +0 -62
- package/dist/src/graphql/reactor/adapters.d.ts.map +0 -1
- package/dist/src/graphql/reactor/adapters.js +0 -271
- package/dist/src/graphql/reactor/adapters.js.map +0 -1
- package/dist/src/graphql/reactor/factory.d.ts +0 -105
- package/dist/src/graphql/reactor/factory.d.ts.map +0 -1
- package/dist/src/graphql/reactor/factory.js +0 -7
- package/dist/src/graphql/reactor/factory.js.map +0 -1
- package/dist/src/graphql/reactor/gen/graphql.d.ts +0 -1489
- package/dist/src/graphql/reactor/gen/graphql.d.ts.map +0 -1
- package/dist/src/graphql/reactor/gen/graphql.js +0 -731
- package/dist/src/graphql/reactor/gen/graphql.js.map +0 -1
- package/dist/src/graphql/reactor/index.d.ts +0 -4
- package/dist/src/graphql/reactor/index.d.ts.map +0 -1
- package/dist/src/graphql/reactor/index.js +0 -4
- package/dist/src/graphql/reactor/index.js.map +0 -1
- package/dist/src/graphql/reactor/operations.graphql +0 -443
- package/dist/src/graphql/reactor/pubsub.d.ts +0 -27
- package/dist/src/graphql/reactor/pubsub.d.ts.map +0 -1
- package/dist/src/graphql/reactor/pubsub.js +0 -93
- package/dist/src/graphql/reactor/pubsub.js.map +0 -1
- package/dist/src/graphql/reactor/requester.d.ts +0 -4
- package/dist/src/graphql/reactor/requester.d.ts.map +0 -1
- package/dist/src/graphql/reactor/requester.js +0 -22
- package/dist/src/graphql/reactor/requester.js.map +0 -1
- package/dist/src/graphql/reactor/requester.with-zod.d.ts +0 -4
- package/dist/src/graphql/reactor/requester.with-zod.d.ts.map +0 -1
- package/dist/src/graphql/reactor/requester.with-zod.js +0 -129
- package/dist/src/graphql/reactor/requester.with-zod.js.map +0 -1
- package/dist/src/graphql/reactor/resolvers.d.ts +0 -223
- package/dist/src/graphql/reactor/resolvers.d.ts.map +0 -1
- package/dist/src/graphql/reactor/resolvers.js +0 -682
- package/dist/src/graphql/reactor/resolvers.js.map +0 -1
- package/dist/src/graphql/reactor/schema.graphql +0 -475
- package/dist/src/graphql/reactor/subgraph.d.ts +0 -18
- package/dist/src/graphql/reactor/subgraph.d.ts.map +0 -1
- package/dist/src/graphql/reactor/subgraph.js +0 -460
- package/dist/src/graphql/reactor/subgraph.js.map +0 -1
- package/dist/src/graphql/reactor/validation.d.ts +0 -348
- package/dist/src/graphql/reactor/validation.d.ts.map +0 -1
- package/dist/src/graphql/reactor/validation.js +0 -167
- package/dist/src/graphql/reactor/validation.js.map +0 -1
- package/dist/src/graphql/sse.d.ts +0 -35
- package/dist/src/graphql/sse.d.ts.map +0 -1
- package/dist/src/graphql/sse.js +0 -29
- package/dist/src/graphql/sse.js.map +0 -1
- package/dist/src/graphql/system/env/getters.d.ts +0 -2
- package/dist/src/graphql/system/env/getters.d.ts.map +0 -1
- package/dist/src/graphql/system/env/getters.js +0 -4
- package/dist/src/graphql/system/env/getters.js.map +0 -1
- package/dist/src/graphql/system/env/index.d.ts +0 -2
- package/dist/src/graphql/system/env/index.d.ts.map +0 -1
- package/dist/src/graphql/system/env/index.js +0 -5
- package/dist/src/graphql/system/env/index.js.map +0 -1
- package/dist/src/graphql/system/index.d.ts +0 -2
- package/dist/src/graphql/system/index.d.ts.map +0 -1
- package/dist/src/graphql/system/index.js +0 -2
- package/dist/src/graphql/system/index.js.map +0 -1
- package/dist/src/graphql/system/types.d.ts +0 -2
- package/dist/src/graphql/system/types.d.ts.map +0 -1
- package/dist/src/graphql/system/types.js +0 -2
- package/dist/src/graphql/system/types.js.map +0 -1
- package/dist/src/graphql/temp-hack-rwa-type-defs.d.ts +0 -57
- package/dist/src/graphql/temp-hack-rwa-type-defs.d.ts.map +0 -1
- package/dist/src/graphql/temp-hack-rwa-type-defs.js +0 -2
- package/dist/src/graphql/temp-hack-rwa-type-defs.js.map +0 -1
- package/dist/src/graphql/types.d.ts +0 -102
- package/dist/src/graphql/types.d.ts.map +0 -1
- package/dist/src/graphql/types.js +0 -2
- package/dist/src/graphql/types.js.map +0 -1
- package/dist/src/graphql/utils.d.ts +0 -9
- package/dist/src/graphql/utils.d.ts.map +0 -1
- package/dist/src/graphql/utils.js +0 -72
- package/dist/src/graphql/utils.js.map +0 -1
- package/dist/src/graphql/websocket.d.ts +0 -3
- package/dist/src/graphql/websocket.d.ts.map +0 -1
- package/dist/src/graphql/websocket.js +0 -15
- package/dist/src/graphql/websocket.js.map +0 -1
- package/dist/src/migrations/001_create_document_permissions.d.ts +0 -4
- package/dist/src/migrations/001_create_document_permissions.d.ts.map +0 -1
- package/dist/src/migrations/001_create_document_permissions.js +0 -91
- package/dist/src/migrations/001_create_document_permissions.js.map +0 -1
- package/dist/src/migrations/002_add_document_protection.d.ts +0 -4
- package/dist/src/migrations/002_add_document_protection.d.ts.map +0 -1
- package/dist/src/migrations/002_add_document_protection.js +0 -18
- package/dist/src/migrations/002_add_document_protection.js.map +0 -1
- package/dist/src/migrations/index.d.ts +0 -10
- package/dist/src/migrations/index.d.ts.map +0 -1
- package/dist/src/migrations/index.js +0 -58
- package/dist/src/migrations/index.js.map +0 -1
- package/dist/src/packages/http-loader.d.ts +0 -59
- package/dist/src/packages/http-loader.d.ts.map +0 -1
- package/dist/src/packages/http-loader.js +0 -203
- package/dist/src/packages/http-loader.js.map +0 -1
- package/dist/src/packages/https-hooks.d.mts +0 -37
- package/dist/src/packages/https-hooks.d.mts.map +0 -1
- package/dist/src/packages/https-hooks.mjs +0 -95
- package/dist/src/packages/https-hooks.mjs.map +0 -1
- package/dist/src/packages/import-loader.d.ts +0 -14
- package/dist/src/packages/import-loader.d.ts.map +0 -1
- package/dist/src/packages/import-loader.js +0 -47
- package/dist/src/packages/import-loader.js.map +0 -1
- package/dist/src/packages/import-resolver.d.ts +0 -5
- package/dist/src/packages/import-resolver.d.ts.map +0 -1
- package/dist/src/packages/import-resolver.js +0 -127
- package/dist/src/packages/import-resolver.js.map +0 -1
- package/dist/src/packages/package-manager.d.ts +0 -33
- package/dist/src/packages/package-manager.d.ts.map +0 -1
- package/dist/src/packages/package-manager.js +0 -216
- package/dist/src/packages/package-manager.js.map +0 -1
- package/dist/src/packages/types.d.ts +0 -39
- package/dist/src/packages/types.d.ts.map +0 -1
- package/dist/src/packages/types.js +0 -2
- package/dist/src/packages/types.js.map +0 -1
- package/dist/src/packages/util.d.ts +0 -26
- package/dist/src/packages/util.d.ts.map +0 -1
- package/dist/src/packages/util.js +0 -85
- package/dist/src/packages/util.js.map +0 -1
- package/dist/src/packages/vite-loader.d.ts +0 -25
- package/dist/src/packages/vite-loader.d.ts.map +0 -1
- package/dist/src/packages/vite-loader.js +0 -171
- package/dist/src/packages/vite-loader.js.map +0 -1
- package/dist/src/server.d.ts +0 -55
- package/dist/src/server.d.ts.map +0 -1
- package/dist/src/server.js +0 -351
- package/dist/src/server.js.map +0 -1
- package/dist/src/services/auth.service.d.ts +0 -53
- package/dist/src/services/auth.service.d.ts.map +0 -1
- package/dist/src/services/auth.service.js +0 -165
- package/dist/src/services/auth.service.js.map +0 -1
- package/dist/src/services/authorization.service.d.ts +0 -70
- package/dist/src/services/authorization.service.d.ts.map +0 -1
- package/dist/src/services/authorization.service.js +0 -155
- package/dist/src/services/authorization.service.js.map +0 -1
- package/dist/src/services/document-permission.service.d.ts +0 -241
- package/dist/src/services/document-permission.service.d.ts.map +0 -1
- package/dist/src/services/document-permission.service.js +0 -791
- package/dist/src/services/document-permission.service.js.map +0 -1
- package/dist/src/services/package-management.service.d.ts +0 -32
- package/dist/src/services/package-management.service.d.ts.map +0 -1
- package/dist/src/services/package-management.service.js +0 -95
- package/dist/src/services/package-management.service.js.map +0 -1
- package/dist/src/services/package-storage.d.ts +0 -23
- package/dist/src/services/package-storage.d.ts.map +0 -1
- package/dist/src/services/package-storage.js +0 -19
- package/dist/src/services/package-storage.js.map +0 -1
- package/dist/src/tracing.d.ts +0 -4
- package/dist/src/tracing.d.ts.map +0 -1
- package/dist/src/tracing.js +0 -146
- package/dist/src/tracing.js.map +0 -1
- package/dist/src/types.d.ts +0 -26
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -2
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils/create-schema.d.ts +0 -36
- package/dist/src/utils/create-schema.d.ts.map +0 -1
- package/dist/src/utils/create-schema.js +0 -728
- package/dist/src/utils/create-schema.js.map +0 -1
- package/dist/src/utils/db.d.ts +0 -82
- package/dist/src/utils/db.d.ts.map +0 -1
- package/dist/src/utils/db.js +0 -101
- package/dist/src/utils/db.js.map +0 -1
- package/dist/src/utils/drive-url.d.ts +0 -2
- package/dist/src/utils/drive-url.d.ts.map +0 -1
- package/dist/src/utils/drive-url.js +0 -3
- package/dist/src/utils/drive-url.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -4
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js +0 -4
- package/dist/src/utils/index.js.map +0 -1
- package/dist/test/auth-chain.test.d.ts +0 -12
- package/dist/test/auth-chain.test.d.ts.map +0 -1
- package/dist/test/auth-chain.test.js +0 -157
- package/dist/test/auth-chain.test.js.map +0 -1
- package/dist/test/auth.service.test.d.ts +0 -10
- package/dist/test/auth.service.test.d.ts.map +0 -1
- package/dist/test/auth.service.test.js +0 -141
- package/dist/test/auth.service.test.js.map +0 -1
- package/dist/test/authorization.service.test.d.ts +0 -2
- package/dist/test/authorization.service.test.d.ts.map +0 -1
- package/dist/test/authorization.service.test.js +0 -252
- package/dist/test/authorization.service.test.js.map +0 -1
- package/dist/test/connect-switchboard-reshuffle-convergence.test.d.ts +0 -2
- package/dist/test/connect-switchboard-reshuffle-convergence.test.d.ts.map +0 -1
- package/dist/test/connect-switchboard-reshuffle-convergence.test.js +0 -204
- package/dist/test/connect-switchboard-reshuffle-convergence.test.js.map +0 -1
- package/dist/test/connect-switchboard-sync.test.d.ts +0 -2
- package/dist/test/connect-switchboard-sync.test.d.ts.map +0 -1
- package/dist/test/connect-switchboard-sync.test.js +0 -633
- package/dist/test/connect-switchboard-sync.test.js.map +0 -1
- package/dist/test/document-drive-subgraph.test.d.ts +0 -2
- package/dist/test/document-drive-subgraph.test.d.ts.map +0 -1
- package/dist/test/document-drive-subgraph.test.js +0 -244
- package/dist/test/document-drive-subgraph.test.js.map +0 -1
- package/dist/test/document-model-subgraph-permissions.test.d.ts +0 -2
- package/dist/test/document-model-subgraph-permissions.test.d.ts.map +0 -1
- package/dist/test/document-model-subgraph-permissions.test.js +0 -587
- package/dist/test/document-model-subgraph-permissions.test.js.map +0 -1
- package/dist/test/document-permission.service.test.d.ts +0 -2
- package/dist/test/document-permission.service.test.d.ts.map +0 -1
- package/dist/test/document-permission.service.test.js +0 -480
- package/dist/test/document-permission.service.test.js.map +0 -1
- package/dist/test/drive-info-endpoint.test.d.ts +0 -2
- package/dist/test/drive-info-endpoint.test.d.ts.map +0 -1
- package/dist/test/drive-info-endpoint.test.js +0 -123
- package/dist/test/drive-info-endpoint.test.js.map +0 -1
- package/dist/test/fault-injection-sync.test.d.ts +0 -2
- package/dist/test/fault-injection-sync.test.d.ts.map +0 -1
- package/dist/test/fault-injection-sync.test.js +0 -197
- package/dist/test/fault-injection-sync.test.js.map +0 -1
- package/dist/test/gateway/adapter-gateway-apollo.test.d.ts +0 -2
- package/dist/test/gateway/adapter-gateway-apollo.test.d.ts.map +0 -1
- package/dist/test/gateway/adapter-gateway-apollo.test.js +0 -206
- package/dist/test/gateway/adapter-gateway-apollo.test.js.map +0 -1
- package/dist/test/gateway/adapter-gateway-mercurius.test.d.ts +0 -2
- package/dist/test/gateway/adapter-gateway-mercurius.test.d.ts.map +0 -1
- package/dist/test/gateway/adapter-gateway-mercurius.test.js +0 -23
- package/dist/test/gateway/adapter-gateway-mercurius.test.js.map +0 -1
- package/dist/test/gateway/adapter-http-express.test.d.ts +0 -2
- package/dist/test/gateway/adapter-http-express.test.d.ts.map +0 -1
- package/dist/test/gateway/adapter-http-express.test.js +0 -17
- package/dist/test/gateway/adapter-http-express.test.js.map +0 -1
- package/dist/test/gateway/adapter-http-fastify.test.d.ts +0 -2
- package/dist/test/gateway/adapter-http-fastify.test.d.ts.map +0 -1
- package/dist/test/gateway/adapter-http-fastify.test.js +0 -17
- package/dist/test/gateway/adapter-http-fastify.test.js.map +0 -1
- package/dist/test/gateway/auth-middleware.test.d.ts +0 -8
- package/dist/test/gateway/auth-middleware.test.d.ts.map +0 -1
- package/dist/test/gateway/auth-middleware.test.js +0 -73
- package/dist/test/gateway/auth-middleware.test.js.map +0 -1
- package/dist/test/gateway/gateway-adapter-contract.d.ts +0 -30
- package/dist/test/gateway/gateway-adapter-contract.d.ts.map +0 -1
- package/dist/test/gateway/gateway-adapter-contract.js +0 -347
- package/dist/test/gateway/gateway-adapter-contract.js.map +0 -1
- package/dist/test/gateway/http-adapter-contract.d.ts +0 -30
- package/dist/test/gateway/http-adapter-contract.d.ts.map +0 -1
- package/dist/test/gateway/http-adapter-contract.js +0 -277
- package/dist/test/gateway/http-adapter-contract.js.map +0 -1
- package/dist/test/graphql-manager.test.d.ts +0 -12
- package/dist/test/graphql-manager.test.d.ts.map +0 -1
- package/dist/test/graphql-manager.test.js +0 -576
- package/dist/test/graphql-manager.test.js.map +0 -1
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.d.ts.map +0 -1
- package/dist/test/index.js +0 -2
- package/dist/test/index.js.map +0 -1
- package/dist/test/permissions-integration.test.d.ts +0 -2
- package/dist/test/permissions-integration.test.d.ts.map +0 -1
- package/dist/test/permissions-integration.test.js +0 -407
- package/dist/test/permissions-integration.test.js.map +0 -1
- package/dist/test/push-backfill.test.d.ts +0 -2
- package/dist/test/push-backfill.test.d.ts.map +0 -1
- package/dist/test/push-backfill.test.js +0 -299
- package/dist/test/push-backfill.test.js.map +0 -1
- package/dist/test/reactor-adapters.test.d.ts +0 -2
- package/dist/test/reactor-adapters.test.d.ts.map +0 -1
- package/dist/test/reactor-adapters.test.js +0 -380
- package/dist/test/reactor-adapters.test.js.map +0 -1
- package/dist/test/reactor-client.test.d.ts +0 -2
- package/dist/test/reactor-client.test.d.ts.map +0 -1
- package/dist/test/reactor-client.test.js +0 -371
- package/dist/test/reactor-client.test.js.map +0 -1
- package/dist/test/reactor-resolvers.test.d.ts +0 -2
- package/dist/test/reactor-resolvers.test.d.ts.map +0 -1
- package/dist/test/reactor-resolvers.test.js +0 -259
- package/dist/test/reactor-resolvers.test.js.map +0 -1
- package/dist/test/reactor-subgraph-permissions.test.d.ts +0 -2
- package/dist/test/reactor-subgraph-permissions.test.d.ts.map +0 -1
- package/dist/test/reactor-subgraph-permissions.test.js +0 -371
- package/dist/test/reactor-subgraph-permissions.test.js.map +0 -1
- package/dist/test/router.test.d.ts +0 -2
- package/dist/test/router.test.d.ts.map +0 -1
- package/dist/test/router.test.js +0 -38
- package/dist/test/router.test.js.map +0 -1
- package/dist/test/subscriptions-sse.test.d.ts +0 -2
- package/dist/test/subscriptions-sse.test.d.ts.map +0 -1
- package/dist/test/subscriptions-sse.test.js +0 -264
- package/dist/test/subscriptions-sse.test.js.map +0 -1
- package/dist/test/subscriptions.test.d.ts +0 -2
- package/dist/test/subscriptions.test.d.ts.map +0 -1
- package/dist/test/subscriptions.test.js +0 -248
- package/dist/test/subscriptions.test.js.map +0 -1
- package/dist/test/utils/gql-resolver-bridge.d.ts +0 -15
- package/dist/test/utils/gql-resolver-bridge.d.ts.map +0 -1
- package/dist/test/utils/gql-resolver-bridge.js +0 -89
- package/dist/test/utils/gql-resolver-bridge.js.map +0 -1
- package/dist/test/utils.d.ts +0 -6
- package/dist/test/utils.d.ts.map +0 -1
- package/dist/test/utils.js +0 -13
- package/dist/test/utils.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -39
- package/dist/vitest.config.js.map +0 -1
|
@@ -1,728 +0,0 @@
|
|
|
1
|
-
import { buildSubgraphSchema } from "@apollo/subgraph";
|
|
2
|
-
import { typeDefs as scalarsTypeDefs } from "@powerhousedao/document-engineering/graphql";
|
|
3
|
-
import { camelCase, pascalCase } from "change-case";
|
|
4
|
-
import { childLogger } from "document-model";
|
|
5
|
-
import { Kind, parse, print } from "graphql";
|
|
6
|
-
import { gql } from "graphql-tag";
|
|
7
|
-
import { GraphQLJSONObject } from "graphql-type-json";
|
|
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
|
-
`;
|
|
19
|
-
/**
|
|
20
|
-
* Strip scalar definitions from a DocumentNode to avoid duplicates
|
|
21
|
-
* when combining with other schemas that define the same scalars.
|
|
22
|
-
*/
|
|
23
|
-
const stripScalarDefinitions = (doc) => {
|
|
24
|
-
const filteredDefinitions = doc.definitions.filter((def) => def.kind !== Kind.SCALAR_TYPE_DEFINITION);
|
|
25
|
-
return print({ kind: Kind.DOCUMENT, definitions: filteredDefinitions });
|
|
26
|
-
};
|
|
27
|
-
export const buildSubgraphSchemaModule = (documentModels, resolvers, typeDefs) => {
|
|
28
|
-
const newResolvers = {
|
|
29
|
-
...resolvers,
|
|
30
|
-
JSONObject: GraphQLJSONObject,
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
typeDefs: getDocumentModelTypeDefs(documentModels, typeDefs),
|
|
34
|
-
resolvers: newResolvers,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export const createSchema = (documentModels, resolvers, typeDefs) => {
|
|
38
|
-
return buildSubgraphSchema(buildSubgraphSchemaModule(documentModels, resolvers, typeDefs));
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Create a merged GraphQL schema from multiple subgraph modules.
|
|
42
|
-
* Uses buildSubgraphSchema's array overload to combine type definitions
|
|
43
|
-
* and resolvers from multiple subgraphs into a single executable schema.
|
|
44
|
-
*/
|
|
45
|
-
export const createMergedSchema = (modules) => {
|
|
46
|
-
return buildSubgraphSchema(modules);
|
|
47
|
-
};
|
|
48
|
-
export function getDocumentModelSchemaName(documentModel) {
|
|
49
|
-
return pascalCase(documentModel.name.replaceAll("/", " "));
|
|
50
|
-
}
|
|
51
|
-
export const getDocumentModelTypeDefs = (documentModels, typeDefs) => {
|
|
52
|
-
let dmSchema = "";
|
|
53
|
-
const addedDocumentModels = new Set();
|
|
54
|
-
documentModels.forEach(({ documentModel }) => {
|
|
55
|
-
const dmSchemaName = getDocumentModelSchemaName(documentModel.global);
|
|
56
|
-
if (addedDocumentModels.has(dmSchemaName)) {
|
|
57
|
-
logger.debug(`Skipping document model with duplicate name: ${dmSchemaName}`);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
addedDocumentModels.add(dmSchemaName);
|
|
61
|
-
// Use only the latest specification to avoid duplicate type definitions
|
|
62
|
-
// when a document model has multiple versions (e.g. v1, v2).
|
|
63
|
-
const latestSpec = documentModel.global.specifications.at(-1);
|
|
64
|
-
const globalSchema = latestSpec?.state.global.schema ?? "";
|
|
65
|
-
const localSchema = latestSpec?.state.local.schema ?? "";
|
|
66
|
-
let tmpDmSchema = `
|
|
67
|
-
${globalSchema
|
|
68
|
-
.replaceAll("scalar DateTime", "")
|
|
69
|
-
.replaceAll(/input (.*?) {[\s\S]*?}/g, "")};
|
|
70
|
-
|
|
71
|
-
${localSchema
|
|
72
|
-
.replaceAll("scalar DateTime", "")
|
|
73
|
-
.replaceAll(/input (.*?) {[\s\S]*?}/g, "")
|
|
74
|
-
.replaceAll("type AccountSnapshotLocalState", "")
|
|
75
|
-
.replaceAll("type BudgetStatementLocalState", "")
|
|
76
|
-
.replaceAll("type ScopeFrameworkLocalState", "")};
|
|
77
|
-
|
|
78
|
-
\n`;
|
|
79
|
-
const found = tmpDmSchema.match(/(type|enum|union|interface)\s+(\w+)[\s{]/g);
|
|
80
|
-
const trimmedFound = found?.map((f) => f
|
|
81
|
-
.replaceAll("type ", "")
|
|
82
|
-
.replaceAll("enum ", "")
|
|
83
|
-
.replaceAll("union ", "")
|
|
84
|
-
.replaceAll("interface ", "")
|
|
85
|
-
.replaceAll("{", "")
|
|
86
|
-
.trim());
|
|
87
|
-
trimmedFound?.forEach((f) => {
|
|
88
|
-
// Create a regex that matches the type name with proper boundaries
|
|
89
|
-
const typeRegex = new RegExp(
|
|
90
|
-
// Match type references in various GraphQL contexts
|
|
91
|
-
`(?<![_A-Za-z0-9])(${f})(?![_A-Za-z0-9])|` + // Basic type references
|
|
92
|
-
`\\[(${f})\\]|` + // Array types without nullability
|
|
93
|
-
`\\[(${f})!\\]|` + // Array of non-null types
|
|
94
|
-
`\\[(${f})\\]!|` + // Non-null array of types
|
|
95
|
-
`\\[(${f})!\\]!`, // Non-null array of non-null types
|
|
96
|
-
"g");
|
|
97
|
-
tmpDmSchema = tmpDmSchema.replace(typeRegex, (match, p1, p2, p3, p4, p5) => {
|
|
98
|
-
// If it's an array type, preserve the brackets and ! while replacing the type name
|
|
99
|
-
if (match.startsWith("[")) {
|
|
100
|
-
return match.replace(p2 || p3 || p4 || p5, `${dmSchemaName}_${p2 || p3 || p4 || p5}`);
|
|
101
|
-
}
|
|
102
|
-
// Basic type reference
|
|
103
|
-
return `${dmSchemaName}_${p1}`;
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
dmSchema += tmpDmSchema;
|
|
107
|
-
dmSchema += `
|
|
108
|
-
type ${dmSchemaName} implements IDocument {
|
|
109
|
-
id: String!
|
|
110
|
-
name: String!
|
|
111
|
-
documentType: String!
|
|
112
|
-
operations(skip: Int, first: Int): [Operation!]!
|
|
113
|
-
revision: Int!
|
|
114
|
-
createdAtUtcIso: DateTime!
|
|
115
|
-
lastModifiedAtUtcIso: DateTime!
|
|
116
|
-
${dmSchemaName !== "DocumentModel" ? `initialState: ${dmSchemaName}_${dmSchemaName}State!` : ""}
|
|
117
|
-
${dmSchemaName !== "DocumentModel" ? `state: ${dmSchemaName}_${dmSchemaName}State!` : ""}
|
|
118
|
-
stateJSON: JSONObject
|
|
119
|
-
}\n`;
|
|
120
|
-
});
|
|
121
|
-
// add the mutation and query types
|
|
122
|
-
const schema = gql `
|
|
123
|
-
scalar JSONObject
|
|
124
|
-
${scalarsTypeDefs.join("\n").replaceAll(";", "")}
|
|
125
|
-
|
|
126
|
-
type PHOperationContext {
|
|
127
|
-
signer: Signer
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
type Signer {
|
|
131
|
-
user: SignerUser
|
|
132
|
-
app: SignerApp
|
|
133
|
-
signatures: [String!]!
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
type SignerUser {
|
|
137
|
-
address: String!
|
|
138
|
-
networkId: String!
|
|
139
|
-
chainId: Int!
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
type SignerApp {
|
|
143
|
-
name: String!
|
|
144
|
-
key: String!
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
type Operation {
|
|
148
|
-
id: String!
|
|
149
|
-
type: String!
|
|
150
|
-
index: Int!
|
|
151
|
-
timestampUtcMs: DateTime!
|
|
152
|
-
hash: String!
|
|
153
|
-
skip: Int
|
|
154
|
-
inputText: String
|
|
155
|
-
error: String
|
|
156
|
-
context: PHOperationContext
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
interface IDocument {
|
|
160
|
-
id: String!
|
|
161
|
-
name: String!
|
|
162
|
-
documentType: String!
|
|
163
|
-
revision: Int!
|
|
164
|
-
createdAtUtcIso: DateTime!
|
|
165
|
-
lastModifiedAtUtcIso: DateTime!
|
|
166
|
-
operations(first: Int, skip: Int): [Operation!]!
|
|
167
|
-
stateJSON: JSONObject
|
|
168
|
-
}
|
|
169
|
-
${dmSchema.replaceAll(";", "")}
|
|
170
|
-
|
|
171
|
-
type GqlDocument implements IDocument {
|
|
172
|
-
id: String!
|
|
173
|
-
name: String!
|
|
174
|
-
documentType: String!
|
|
175
|
-
revision: Int!
|
|
176
|
-
createdAtUtcIso: DateTime!
|
|
177
|
-
lastModifiedAtUtcIso: DateTime!
|
|
178
|
-
operations(first: Int, skip: Int): [Operation!]!
|
|
179
|
-
stateJSON: JSONObject
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
type DriveDocument implements IDocument {
|
|
183
|
-
id: String!
|
|
184
|
-
name: String!
|
|
185
|
-
documentType: String!
|
|
186
|
-
revision: Int!
|
|
187
|
-
createdAtUtcIso: DateTime!
|
|
188
|
-
lastModifiedAtUtcIso: DateTime!
|
|
189
|
-
operations(first: Int, skip: Int): [Operation!]!
|
|
190
|
-
stateJSON: JSONObject
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
${stripScalarDefinitions(typeDefs)}
|
|
194
|
-
`;
|
|
195
|
-
return schema;
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Extract type names from a GraphQL schema.
|
|
199
|
-
* @param {string} schema - GraphQL schema string
|
|
200
|
-
* @returns {string[]} Array of type names
|
|
201
|
-
*/
|
|
202
|
-
function extractTypeNames(schema) {
|
|
203
|
-
const found = schema.match(/(type|enum|union|interface|input)\s+(\w+)[\s{]/g);
|
|
204
|
-
if (!found)
|
|
205
|
-
return [];
|
|
206
|
-
return found.map((f) => f
|
|
207
|
-
.replaceAll("type ", "")
|
|
208
|
-
.replaceAll("enum ", "")
|
|
209
|
-
.replaceAll("union ", "")
|
|
210
|
-
.replaceAll("interface ", "")
|
|
211
|
-
.replaceAll("input ", "")
|
|
212
|
-
.replaceAll("{", "")
|
|
213
|
-
.trim());
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Extract input type definitions from a GraphQL schema.
|
|
217
|
-
* @param {string} schema - GraphQL schema string
|
|
218
|
-
* @param {Set<string>} excludeTypeNames - Type names to exclude from extraction
|
|
219
|
-
* @returns {string} All input type definitions as a string
|
|
220
|
-
*/
|
|
221
|
-
function extractInputTypeDefinitions(schema, excludeTypeNames = new Set()) {
|
|
222
|
-
// Match input type blocks: input TypeName { ... }
|
|
223
|
-
const inputTypeRegex = /input\s+(\w+)\s*\{[^}]*\}/g;
|
|
224
|
-
const matches = [];
|
|
225
|
-
let match;
|
|
226
|
-
while ((match = inputTypeRegex.exec(schema)) !== null) {
|
|
227
|
-
const typeName = match[1];
|
|
228
|
-
// Skip if this type name is in the exclusion set
|
|
229
|
-
if (!excludeTypeNames.has(typeName)) {
|
|
230
|
-
matches.push(match[0]);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (matches.length === 0)
|
|
234
|
-
return "";
|
|
235
|
-
return matches.join("\n\n");
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Extract the root state type name from a scope's GraphQL schema.
|
|
239
|
-
* Uses the naming convention: {DocumentName}State for global,
|
|
240
|
-
* {DocumentName}{PascalScope}State for other scopes (e.g., DocumentDriveLocalState).
|
|
241
|
-
* Falls back to the last ObjectTypeDefinition (root types are conventionally last).
|
|
242
|
-
*/
|
|
243
|
-
function extractRootTypeName(schema, documentName, scopeName) {
|
|
244
|
-
try {
|
|
245
|
-
const ast = parse(schema);
|
|
246
|
-
// Try conventions:
|
|
247
|
-
// 1. {DocumentName}State for global, {DocumentName}{Scope}State otherwise
|
|
248
|
-
// 2. {DocumentName}GlobalState (DocumentModel uses this variant)
|
|
249
|
-
const scopeSuffix = scopeName === "global" ? "" : pascalCase(scopeName);
|
|
250
|
-
const candidates = [
|
|
251
|
-
`${documentName}${scopeSuffix}State`,
|
|
252
|
-
`${documentName}${pascalCase(scopeName)}State`,
|
|
253
|
-
];
|
|
254
|
-
let lastObjectType = null;
|
|
255
|
-
for (const def of ast.definitions) {
|
|
256
|
-
if (def.kind === Kind.OBJECT_TYPE_DEFINITION) {
|
|
257
|
-
if (candidates.includes(def.name.value)) {
|
|
258
|
-
return def.name.value;
|
|
259
|
-
}
|
|
260
|
-
lastObjectType = def.name.value;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// Fallback: last object type (root state types are defined last by convention)
|
|
264
|
-
return lastObjectType;
|
|
265
|
-
}
|
|
266
|
-
catch {
|
|
267
|
-
// ignore parse errors
|
|
268
|
-
}
|
|
269
|
-
return null;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Convert a GraphQL output type AST node to an optional input type string.
|
|
273
|
-
* Strips non-null markers and converts object type references to Input suffix.
|
|
274
|
-
*/
|
|
275
|
-
function convertTypeNodeToInput(typeNode, objectNames, unionNames, interfaceNames) {
|
|
276
|
-
if (typeNode.kind === Kind.NON_NULL_TYPE && typeNode.type) {
|
|
277
|
-
return convertTypeNodeToInput(typeNode.type, objectNames, unionNames, interfaceNames);
|
|
278
|
-
}
|
|
279
|
-
if (typeNode.kind === Kind.LIST_TYPE && typeNode.type) {
|
|
280
|
-
const inner = convertTypeNodeToInput(typeNode.type, objectNames, unionNames, interfaceNames);
|
|
281
|
-
return `[${inner}]`;
|
|
282
|
-
}
|
|
283
|
-
if (typeNode.kind === Kind.NAMED_TYPE && typeNode.name) {
|
|
284
|
-
const name = typeNode.name.value;
|
|
285
|
-
if (objectNames.has(name))
|
|
286
|
-
return `${name}Input`;
|
|
287
|
-
if (unionNames.has(name) || interfaceNames.has(name))
|
|
288
|
-
return "JSONObject";
|
|
289
|
-
return name;
|
|
290
|
-
}
|
|
291
|
-
return "JSONObject";
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Generate GraphQL input type definitions from a state schema string.
|
|
295
|
-
* Converts output type definitions to input types with all fields optional.
|
|
296
|
-
* - Object type references get Input suffix
|
|
297
|
-
* - Union/interface references become JSONObject
|
|
298
|
-
* - Enums and scalars remain unchanged
|
|
299
|
-
*/
|
|
300
|
-
function generateStateInputTypes(stateSchema, excludeTypeNames) {
|
|
301
|
-
if (!stateSchema || !stateSchema.trim())
|
|
302
|
-
return "";
|
|
303
|
-
let ast;
|
|
304
|
-
try {
|
|
305
|
-
ast = parse(stateSchema);
|
|
306
|
-
}
|
|
307
|
-
catch {
|
|
308
|
-
return "";
|
|
309
|
-
}
|
|
310
|
-
const enumNames = new Set();
|
|
311
|
-
const unionNames = new Set();
|
|
312
|
-
const interfaceNames = new Set();
|
|
313
|
-
const objectNames = new Set();
|
|
314
|
-
const existingInputNames = new Set();
|
|
315
|
-
for (const def of ast.definitions) {
|
|
316
|
-
switch (def.kind) {
|
|
317
|
-
case Kind.ENUM_TYPE_DEFINITION:
|
|
318
|
-
enumNames.add(def.name.value);
|
|
319
|
-
break;
|
|
320
|
-
case Kind.UNION_TYPE_DEFINITION:
|
|
321
|
-
unionNames.add(def.name.value);
|
|
322
|
-
break;
|
|
323
|
-
case Kind.INTERFACE_TYPE_DEFINITION:
|
|
324
|
-
interfaceNames.add(def.name.value);
|
|
325
|
-
break;
|
|
326
|
-
case Kind.OBJECT_TYPE_DEFINITION:
|
|
327
|
-
objectNames.add(def.name.value);
|
|
328
|
-
break;
|
|
329
|
-
case Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
330
|
-
existingInputNames.add(def.name.value);
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
const inputTypes = [];
|
|
335
|
-
for (const def of ast.definitions) {
|
|
336
|
-
if (def.kind !== Kind.OBJECT_TYPE_DEFINITION)
|
|
337
|
-
continue;
|
|
338
|
-
// Skip if an input type with the same name already exists in the schema
|
|
339
|
-
// or in operation schemas (to avoid duplicates with moduleSchemas)
|
|
340
|
-
const inputName = `${def.name.value}Input`;
|
|
341
|
-
if (existingInputNames.has(inputName))
|
|
342
|
-
continue;
|
|
343
|
-
if (excludeTypeNames?.has(inputName))
|
|
344
|
-
continue;
|
|
345
|
-
const fields = def.fields ?? [];
|
|
346
|
-
if (fields.length === 0)
|
|
347
|
-
continue;
|
|
348
|
-
const inputFields = fields.map((field) => {
|
|
349
|
-
const fieldName = field.name.value;
|
|
350
|
-
const fieldType = convertTypeNodeToInput(field.type, objectNames, unionNames, interfaceNames);
|
|
351
|
-
return ` ${fieldName}: ${fieldType}`;
|
|
352
|
-
});
|
|
353
|
-
inputTypes.push(`input ${def.name.value}Input {\n${inputFields.join("\n")}\n}`);
|
|
354
|
-
}
|
|
355
|
-
return inputTypes.join("\n\n");
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Apply type prefixes to GraphQL schema to namespace types and avoid collisions.
|
|
359
|
-
* Inlined from @powerhousedao/common/utils to avoid ES module import issues.
|
|
360
|
-
* @param {string} schema - GraphQL schema string
|
|
361
|
-
* @param {string} prefix - Prefix to apply to type names
|
|
362
|
-
* @param {string[]} externalTypeNames - Type names from other schemas to also prefix
|
|
363
|
-
* @returns {string} Schema with prefixed types
|
|
364
|
-
*/
|
|
365
|
-
function applyGraphQLTypePrefixes(schema, prefix, externalTypeNames = []) {
|
|
366
|
-
if (!schema || !schema.trim()) {
|
|
367
|
-
return schema;
|
|
368
|
-
}
|
|
369
|
-
let processedSchema = schema;
|
|
370
|
-
// Find types defined in this schema
|
|
371
|
-
const localTypeNames = extractTypeNames(schema);
|
|
372
|
-
// Combine with external type names (remove duplicates)
|
|
373
|
-
const allTypeNames = [...new Set([...localTypeNames, ...externalTypeNames])];
|
|
374
|
-
if (allTypeNames.length === 0) {
|
|
375
|
-
return schema;
|
|
376
|
-
}
|
|
377
|
-
allTypeNames.forEach((typeName) => {
|
|
378
|
-
const typeRegex = new RegExp(
|
|
379
|
-
// Match type references in various GraphQL contexts
|
|
380
|
-
`(?<![_A-Za-z0-9])(${typeName})(?![_A-Za-z0-9])|` +
|
|
381
|
-
`\\[(${typeName})\\]|` +
|
|
382
|
-
`\\[(${typeName})!\\]|` +
|
|
383
|
-
`\\[(${typeName})\\]!|` +
|
|
384
|
-
`\\[(${typeName})!\\]!`, "g");
|
|
385
|
-
processedSchema = processedSchema.replace(typeRegex, (match, p1, p2, p3, p4, p5) => {
|
|
386
|
-
if (match.startsWith("[")) {
|
|
387
|
-
return match.replace((p2 || p3 || p4 || p5), `${prefix}_${p2 || p3 || p4 || p5}`);
|
|
388
|
-
}
|
|
389
|
-
// Basic type reference
|
|
390
|
-
return `${prefix}_${p1}`;
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
return processedSchema;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Generate a GraphQL schema for a document model.
|
|
397
|
-
*
|
|
398
|
-
* @param documentModel - The document model global state
|
|
399
|
-
* @param options - Schema generation options
|
|
400
|
-
* @returns GraphQL DocumentNode
|
|
401
|
-
*/
|
|
402
|
-
export function generateDocumentModelSchema(documentModel, options = {}) {
|
|
403
|
-
const { useNewApi = false } = options;
|
|
404
|
-
const specification = documentModel.specifications.at(-1);
|
|
405
|
-
const documentName = getDocumentModelSchemaName(documentModel);
|
|
406
|
-
const globalStateSchema = specification?.state.global.schema;
|
|
407
|
-
const localStateSchema = specification?.state.local.schema;
|
|
408
|
-
const globalStateTypeNames = extractTypeNames(globalStateSchema ?? "");
|
|
409
|
-
const localStateTypeNames = extractTypeNames(localStateSchema ?? "");
|
|
410
|
-
const stateTypeNames = [...globalStateTypeNames, ...localStateTypeNames];
|
|
411
|
-
// Collect ALL type names from all operations' schemas
|
|
412
|
-
const allOperationTypeNames = specification?.modules.flatMap((module) => module.operations.flatMap((op) => extractTypeNames(op.schema ?? ""))) ?? [];
|
|
413
|
-
// Combine state types and all operation types for prefixing
|
|
414
|
-
const allTypeNames = [
|
|
415
|
-
...new Set([...stateTypeNames, ...allOperationTypeNames]),
|
|
416
|
-
];
|
|
417
|
-
// Extract input type definitions from state schema, excluding operation-specific inputs
|
|
418
|
-
// (those are already defined in op.schema)
|
|
419
|
-
const operationInputTypeNames = new Set(allOperationTypeNames);
|
|
420
|
-
const stateInputTypes = extractInputTypeDefinitions(globalStateSchema ?? "", operationInputTypeNames);
|
|
421
|
-
const prefixedStateInputTypes = applyGraphQLTypePrefixes(stateInputTypes, documentName, allTypeNames);
|
|
422
|
-
// Helper to check if schema has actual GraphQL type definitions
|
|
423
|
-
const hasValidSchema = (schema) => !!(schema && /\b(input|type|enum|union|interface)\s+\w+/.test(schema));
|
|
424
|
-
// Process state schema types (remove input types, clean up, and prefix)
|
|
425
|
-
const stateSchemaTypes = globalStateSchema
|
|
426
|
-
? applyGraphQLTypePrefixes(globalStateSchema
|
|
427
|
-
.replaceAll("scalar DateTime", "")
|
|
428
|
-
.replaceAll(/input (.*?) {[\s\S]*?}/g, ""), documentName, allTypeNames)
|
|
429
|
-
: "";
|
|
430
|
-
if (useNewApi) {
|
|
431
|
-
// New API: flat queries, typed state, async mutations
|
|
432
|
-
return generateNewApiSchema(documentName, specification, stateSchemaTypes, prefixedStateInputTypes, allTypeNames, hasValidSchema);
|
|
433
|
-
}
|
|
434
|
-
// Legacy API
|
|
435
|
-
return generateLegacyApiSchema(documentName, specification, prefixedStateInputTypes, allTypeNames, hasValidSchema);
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Generate legacy API schema with nested queries
|
|
439
|
-
*/
|
|
440
|
-
function generateLegacyApiSchema(documentName, specification, prefixedStateInputTypes, allTypeNames, hasValidSchema) {
|
|
441
|
-
const createDocumentMutation = `${documentName}_createDocument(name:String!, driveId:String): String`;
|
|
442
|
-
const operationMutations = specification?.modules
|
|
443
|
-
.flatMap((module) => module.operations
|
|
444
|
-
.filter((op) => op.name && hasValidSchema(op.schema))
|
|
445
|
-
.map((op) => `${documentName}_${camelCase(op.name)}(
|
|
446
|
-
driveId: String, docId: PHID, input: ${documentName}_${pascalCase(op.name)}Input): Int`))
|
|
447
|
-
.join("\n ") ?? "";
|
|
448
|
-
const moduleSchemas = specification?.modules
|
|
449
|
-
.filter((module) => module.operations.some((op) => hasValidSchema(op.schema)))
|
|
450
|
-
.map((module) => `"""
|
|
451
|
-
Module: ${pascalCase(module.name)}
|
|
452
|
-
"""
|
|
453
|
-
${module.operations
|
|
454
|
-
.filter((op) => hasValidSchema(op.schema))
|
|
455
|
-
.map((op) => applyGraphQLTypePrefixes(op.schema ?? "", documentName, allTypeNames))
|
|
456
|
-
.join("\n ")}`)
|
|
457
|
-
.join("\n") ?? "";
|
|
458
|
-
return gql `
|
|
459
|
-
"""
|
|
460
|
-
Queries: ${documentName} Document
|
|
461
|
-
"""
|
|
462
|
-
|
|
463
|
-
type ${documentName}Queries {
|
|
464
|
-
getDocument(docId: PHID!, driveId: PHID): ${documentName}
|
|
465
|
-
getDocuments(driveId: String!): [${documentName}!]
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
type Query {
|
|
469
|
-
${documentName}: ${documentName}Queries
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
"""
|
|
473
|
-
Mutations: ${documentName}
|
|
474
|
-
"""
|
|
475
|
-
type Mutation {
|
|
476
|
-
${createDocumentMutation}
|
|
477
|
-
|
|
478
|
-
${operationMutations}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
${prefixedStateInputTypes
|
|
482
|
-
? `"""
|
|
483
|
-
Input Types from State Schema
|
|
484
|
-
"""
|
|
485
|
-
${prefixedStateInputTypes}`
|
|
486
|
-
: ""}
|
|
487
|
-
|
|
488
|
-
${moduleSchemas}`;
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Generate new API schema with flat queries, typed state, and async mutations.
|
|
492
|
-
* Note: State schema types are NOT included here because they are already defined
|
|
493
|
-
* in getDocumentModelTypeDefs() which is used during schema composition.
|
|
494
|
-
* Including them here would cause duplicate type definitions.
|
|
495
|
-
*/
|
|
496
|
-
function generateNewApiSchema(documentName, specification, _stateSchemaTypes, prefixedStateInputTypes, allTypeNames, hasValidSchema) {
|
|
497
|
-
// Use full state type for all document models
|
|
498
|
-
const stateType = `${documentName}_FullState!`;
|
|
499
|
-
// Shared base types for document state structure (same for all document types)
|
|
500
|
-
const sharedBaseTypes = `
|
|
501
|
-
"""Hash configuration for document state"""
|
|
502
|
-
type ${documentName}_PHHashConfig {
|
|
503
|
-
algorithm: String!
|
|
504
|
-
encoding: String!
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
"""Document scope state (same for all document types)"""
|
|
508
|
-
type ${documentName}_PHDocumentScopeState {
|
|
509
|
-
version: Int!
|
|
510
|
-
hash: ${documentName}_PHHashConfig!
|
|
511
|
-
isDeleted: Boolean
|
|
512
|
-
deletedAtUtcIso: String
|
|
513
|
-
deletedBy: String
|
|
514
|
-
deletionReason: String
|
|
515
|
-
}
|
|
516
|
-
`;
|
|
517
|
-
// Full state type with all scopes (auth, document, global, local)
|
|
518
|
-
// Note: DocumentModel uses different naming convention (GlobalState suffix instead of State)
|
|
519
|
-
// For local state, check if the specification defines a local state type
|
|
520
|
-
const localSchema = specification?.state.local.schema ?? "";
|
|
521
|
-
const hasLocalStateType = localSchema.includes(`type ${documentName}LocalState`);
|
|
522
|
-
const globalStateType = documentName === "DocumentModel"
|
|
523
|
-
? `${documentName}_${documentName}GlobalState!`
|
|
524
|
-
: `${documentName}_${documentName}State!`;
|
|
525
|
-
const localStateType = !hasLocalStateType
|
|
526
|
-
? "JSONObject!"
|
|
527
|
-
: `${documentName}_${documentName}LocalState!`;
|
|
528
|
-
const fullStateType = `
|
|
529
|
-
"""Full state with all scopes for ${documentName}"""
|
|
530
|
-
type ${documentName}_FullState {
|
|
531
|
-
auth: JSONObject!
|
|
532
|
-
document: ${documentName}_PHDocumentScopeState!
|
|
533
|
-
global: ${globalStateType}
|
|
534
|
-
local: ${localStateType}
|
|
535
|
-
}
|
|
536
|
-
`;
|
|
537
|
-
// Common input types - use extend to avoid conflicts with other subgraphs
|
|
538
|
-
const commonInputTypes = `
|
|
539
|
-
input ${documentName}_ViewFilterInput {
|
|
540
|
-
branch: String
|
|
541
|
-
scopes: [String!]
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
input ${documentName}_PagingInput {
|
|
545
|
-
limit: Int
|
|
546
|
-
offset: Int
|
|
547
|
-
cursor: String
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
input ${documentName}_SearchFilterInput {
|
|
551
|
-
parentId: String
|
|
552
|
-
identifiers: [String!]
|
|
553
|
-
}
|
|
554
|
-
`;
|
|
555
|
-
// Revision type - imported from shared-schema.ts for consistency with ReactorSubgraph
|
|
556
|
-
// Must be defined in each subgraph for Apollo Federation
|
|
557
|
-
const revisionType = RevisionType;
|
|
558
|
-
// Result types with typed state (or JSONObject for DocumentModel)
|
|
559
|
-
// The state type (${documentName}_${documentName}State) is defined in getDocumentModelTypeDefs()
|
|
560
|
-
// Uses revisionsList with shared Revision type to match ReactorSubgraph pattern
|
|
561
|
-
const resultTypes = `
|
|
562
|
-
"""
|
|
563
|
-
Mutation result type for ${documentName} operations with typed state.
|
|
564
|
-
Matches ReactorSubgraph PHDocument pattern with revisionsList.
|
|
565
|
-
"""
|
|
566
|
-
type ${documentName}MutationResult {
|
|
567
|
-
id: String!
|
|
568
|
-
slug: String
|
|
569
|
-
preferredEditor: String
|
|
570
|
-
name: String!
|
|
571
|
-
documentType: String!
|
|
572
|
-
state: ${stateType}
|
|
573
|
-
revisionsList: [Revision!]!
|
|
574
|
-
createdAtUtcIso: DateTime!
|
|
575
|
-
lastModifiedAtUtcIso: DateTime!
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
"""
|
|
579
|
-
Document with children for ${documentName}
|
|
580
|
-
"""
|
|
581
|
-
type ${documentName}_DocumentWithChildren {
|
|
582
|
-
document: ${documentName}MutationResult!
|
|
583
|
-
childIds: [String!]!
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
"""
|
|
587
|
-
Paginated result type for ${documentName} documents
|
|
588
|
-
"""
|
|
589
|
-
type ${documentName}_DocumentResultPage {
|
|
590
|
-
items: [${documentName}MutationResult!]!
|
|
591
|
-
totalCount: Int!
|
|
592
|
-
hasNextPage: Boolean!
|
|
593
|
-
hasPreviousPage: Boolean!
|
|
594
|
-
cursor: String
|
|
595
|
-
}
|
|
596
|
-
`;
|
|
597
|
-
// Queries nested under ${documentName} namespace
|
|
598
|
-
const queries = `
|
|
599
|
-
type ${documentName}Queries {
|
|
600
|
-
"""Get a specific ${documentName} document by identifier"""
|
|
601
|
-
document(identifier: String!, view: ${documentName}_ViewFilterInput): ${documentName}_DocumentWithChildren
|
|
602
|
-
|
|
603
|
-
"""Get all ${documentName} documents (paged)"""
|
|
604
|
-
documents(paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
|
|
605
|
-
|
|
606
|
-
"""Find ${documentName} documents by search criteria"""
|
|
607
|
-
findDocuments(search: ${documentName}_SearchFilterInput, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
|
|
608
|
-
|
|
609
|
-
"""Get children of a ${documentName} document"""
|
|
610
|
-
documentChildren(parentIdentifier: String!, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
|
|
611
|
-
|
|
612
|
-
"""Get parents of a ${documentName} document"""
|
|
613
|
-
documentParents(childIdentifier: String!, view: ${documentName}_ViewFilterInput, paging: ${documentName}_PagingInput): ${documentName}_DocumentResultPage!
|
|
614
|
-
}
|
|
615
|
-
`;
|
|
616
|
-
// Generate initial state input types for each scope
|
|
617
|
-
let initialStateInputSchema = "";
|
|
618
|
-
if (specification) {
|
|
619
|
-
const scopeFields = [];
|
|
620
|
-
const generatedInputTypeParts = [];
|
|
621
|
-
for (const [scopeName, scopeState] of Object.entries(specification.state)) {
|
|
622
|
-
const schema = scopeState.schema ?? "";
|
|
623
|
-
if (hasValidSchema(schema)) {
|
|
624
|
-
const rootTypeName = extractRootTypeName(schema, documentName, scopeName);
|
|
625
|
-
if (!rootTypeName) {
|
|
626
|
-
scopeFields.push(` ${scopeName}: JSONObject`);
|
|
627
|
-
continue;
|
|
628
|
-
}
|
|
629
|
-
const scopeInputTypes = generateStateInputTypes(schema, new Set(allTypeNames));
|
|
630
|
-
if (!scopeInputTypes) {
|
|
631
|
-
scopeFields.push(` ${scopeName}: JSONObject`);
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
const prefixedScopeInputTypes = applyGraphQLTypePrefixes(scopeInputTypes, documentName, allTypeNames);
|
|
635
|
-
scopeFields.push(` ${scopeName}: ${documentName}_${rootTypeName}Input`);
|
|
636
|
-
generatedInputTypeParts.push(prefixedScopeInputTypes);
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
scopeFields.push(` ${scopeName}: JSONObject`);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (scopeFields.length > 0) {
|
|
643
|
-
const inputTypeDefs = generatedInputTypeParts.join("\n\n");
|
|
644
|
-
const wrapper = `input ${documentName}_InitialStateInput {\n${scopeFields.join("\n")}\n}`;
|
|
645
|
-
initialStateInputSchema = inputTypeDefs
|
|
646
|
-
? `${inputTypeDefs}\n\n${wrapper}`
|
|
647
|
-
: wrapper;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
// Mutations nested under ${documentName} namespace
|
|
651
|
-
const createDocumentMutation = initialStateInputSchema
|
|
652
|
-
? `createDocument(name: String!, parentIdentifier: String, slug: String, preferredEditor: String, initialState: ${documentName}_InitialStateInput): ${documentName}MutationResult!`
|
|
653
|
-
: `createDocument(name: String!, parentIdentifier: String, preferredEditor: String): ${documentName}MutationResult!`;
|
|
654
|
-
const createEmptyDocumentMutation = `createEmptyDocument(parentIdentifier: String): ${documentName}MutationResult!`;
|
|
655
|
-
const operationMutations = specification?.modules
|
|
656
|
-
.flatMap((module) => module.operations
|
|
657
|
-
.filter((op) => op.name && hasValidSchema(op.schema))
|
|
658
|
-
.flatMap((op) => [
|
|
659
|
-
// Sync mutation
|
|
660
|
-
`${camelCase(op.name)}(docId: PHID!, input: ${documentName}_${pascalCase(op.name)}Input!): ${documentName}MutationResult!`,
|
|
661
|
-
// Async mutation
|
|
662
|
-
`${camelCase(op.name)}Async(docId: PHID!, input: ${documentName}_${pascalCase(op.name)}Input!): String!`,
|
|
663
|
-
]))
|
|
664
|
-
.join("\n ") ?? "";
|
|
665
|
-
const moduleSchemas = specification?.modules
|
|
666
|
-
.filter((module) => module.operations.some((op) => hasValidSchema(op.schema)))
|
|
667
|
-
.map((module) => `"""
|
|
668
|
-
Module: ${pascalCase(module.name)}
|
|
669
|
-
"""
|
|
670
|
-
${module.operations
|
|
671
|
-
.filter((op) => hasValidSchema(op.schema))
|
|
672
|
-
.map((op) => applyGraphQLTypePrefixes(op.schema ?? "", documentName, allTypeNames))
|
|
673
|
-
.join("\n ")}`)
|
|
674
|
-
.join("\n") ?? "";
|
|
675
|
-
return gql `
|
|
676
|
-
scalar DateTime
|
|
677
|
-
scalar JSONObject
|
|
678
|
-
|
|
679
|
-
${revisionType}
|
|
680
|
-
|
|
681
|
-
${sharedBaseTypes}
|
|
682
|
-
|
|
683
|
-
${fullStateType}
|
|
684
|
-
|
|
685
|
-
${commonInputTypes}
|
|
686
|
-
|
|
687
|
-
${resultTypes}
|
|
688
|
-
|
|
689
|
-
"""
|
|
690
|
-
Queries: ${documentName} Document
|
|
691
|
-
"""
|
|
692
|
-
${queries}
|
|
693
|
-
|
|
694
|
-
"""
|
|
695
|
-
Mutations: ${documentName}
|
|
696
|
-
"""
|
|
697
|
-
type ${documentName}Mutations {
|
|
698
|
-
${createDocumentMutation}
|
|
699
|
-
${createEmptyDocumentMutation}
|
|
700
|
-
|
|
701
|
-
${operationMutations}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
type Query {
|
|
705
|
-
${documentName}: ${documentName}Queries!
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
type Mutation {
|
|
709
|
-
${documentName}: ${documentName}Mutations!
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
${prefixedStateInputTypes
|
|
713
|
-
? `"""
|
|
714
|
-
Input Types from State Schema
|
|
715
|
-
"""
|
|
716
|
-
${prefixedStateInputTypes}`
|
|
717
|
-
: ""}
|
|
718
|
-
|
|
719
|
-
${initialStateInputSchema
|
|
720
|
-
? `"""
|
|
721
|
-
Input Types for Initial State
|
|
722
|
-
"""
|
|
723
|
-
${initialStateInputSchema}`
|
|
724
|
-
: ""}
|
|
725
|
-
|
|
726
|
-
${moduleSchemas}`;
|
|
727
|
-
}
|
|
728
|
-
//# sourceMappingURL=create-schema.js.map
|