@powerhousedao/reactor-api 6.2.3-dev.70 → 6.2.3-dev.71

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="15ac44c0-1e9f-5725-b675-7e5e00ca51a4")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c8953112-fd9f-50d0-b2fd-b0854a6626b6")}catch(e){}}();
3
3
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
4
4
  import { A as createCanonicalDocumentIdResolver, C as loadSubgraphs, D as AuthService, E as callerSubject, F as AuthenticationRequiredError, I as ForbiddenError, L as MalformedStoredOperationError, M as AuthorizedDocumentHandle, N as createAuthorizationService, O as createCredentialInvalidator, P as AuthEvaluationUnsupportedError, R as RefusalNotRecordedError, S as loadProcessors, T as BaseSubgraph, _ as PACKAGE_MODULE_FAILED, c as piecesFromListModule, d as buildGraphQlDriveDocument, f as buildGraphqlOperation, g as runDetached, h as reportFailure, i as PIECE_SOURCE_LIST, j as AuthorizationPolicy, k as CanonicalDocumentIdResolutionError, l as extractDocumentModels, m as isSubgraphClass, o as pieceListLocation, p as buildGraphqlOperations, s as piecesFromCdnList, t as extractSubgraphs, u as buildGraphQlDocument, v as debounce, w as manifestDeclaredSubgraphs, x as loadDocumentModels, y as extractUpgradeManifests } from "./subgraph-extraction-cSpPp3Hq.mjs";
5
5
  import { A as getDocumentModelTypeDefs, C as createSchema, D as generatedTypesOf, E as generateDocumentModelSchema, F as typeDefinitionNames, I as schema_default$1, M as hasOperationSchemas, N as reservedTypeNames, O as getDocumentModelSchemaName, P as reservedTypeNamesTaken, S as createMergedSchema, T as findSubgraphTypeCollisions, _ as DocumentModelSchemaCache, a as CORE_ORIGIN, b as buildDocumentModelSchema, c as RegistrationOrder, d as decideAdmission, f as describeOrigin, g as describeOwnershipConflicts, h as collectSubgraphClaims, i as inspectionTypeDefs, j as getGeneratedDocumentModelTypes, k as getDocumentModelSubgraphName, l as admitDocumentModels, m as supergraphClaimLosers, n as systemTypeDefs, o as DOCUMENT_MODEL_ORIGIN, p as documentModelSubgraphSources, r as schema_default$2, s as HOST_ORIGIN, t as baseDocumentModels, u as byClaimPriority, v as SubgraphTypeCollisionError, w as documentModelSubgraphTypes, x as buildSubgraphSchemaModule, y as assembleSubgraphTypeDefs } from "./base-document-models-uUQKgXcf.mjs";
@@ -3220,11 +3220,27 @@ async function evaluateActions(reactorClient, args, subject) {
3220
3220
  anyDenied: result.anyDenied
3221
3221
  };
3222
3222
  }
3223
+ const isDocumentNotFound = (error) => error instanceof Error && error.name === "DocumentNotFoundError";
3224
+ /** Refuses a slug another document holds: the reactor would move it to the new one. */
3225
+ async function assertSlugAvailable(reactorClient, slug, documentId) {
3226
+ if (!slug || slug === documentId) return;
3227
+ let holder;
3228
+ try {
3229
+ const id = await reactorClient.resolveIdOrSlug(slug);
3230
+ if (id === documentId) return;
3231
+ holder = `document ${id}`;
3232
+ } catch (error) {
3233
+ if (isDocumentNotFound(error)) return;
3234
+ holder = "two documents";
3235
+ }
3236
+ throw new GraphQLError(`The slug "${slug}" is taken by ${holder}; choose another.`);
3237
+ }
3223
3238
  async function createDocument(reactorClient, args, reactorDriveClient, subject) {
3224
3239
  if (!args.document || typeof args.document !== "object") throw new GraphQLError("Invalid document: must be an object");
3225
3240
  const document = args.document;
3226
3241
  if (!document.header || typeof document.header !== "object") throw new GraphQLError("Invalid document: missing or invalid header");
3227
3242
  const parentIdOrSlug = fromInputMaybe(args.parentIdOrSlug);
3243
+ await assertSlugAvailable(reactorClient, document.header.slug, document.header.id);
3228
3244
  let result;
3229
3245
  try {
3230
3246
  if (parentIdOrSlug) {
@@ -3285,7 +3301,10 @@ async function createDocumentWithInitialState(reactorClient, args, reactorDriveC
3285
3301
  ...scopeState
3286
3302
  };
3287
3303
  if (name) document.header.name = name;
3288
- if (slug) document.header.slug = slug;
3304
+ if (slug) {
3305
+ await assertSlugAvailable(reactorClient, slug);
3306
+ document.header.slug = slug;
3307
+ }
3289
3308
  if (preferredEditor) document.header.meta = {
3290
3309
  ...document.header.meta,
3291
3310
  preferredEditor
@@ -4113,8 +4132,9 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
4113
4132
  let parentIdOrSlug = optionalOneOf(args, "parentIdOrSlug", "parentIdentifier");
4114
4133
  if (parentIdOrSlug) parentIdOrSlug = (await this.assertCanWrite(parentIdOrSlug, ctx)).fetchIdentifier;
4115
4134
  else this.assertCanCreate(ctx);
4135
+ const withHeader = !!(initialState || preferredEditor || slug);
4116
4136
  let createdDoc;
4117
- if (initialState || preferredEditor) createdDoc = await createDocumentWithInitialState(this.reactorClient, {
4137
+ if (withHeader) createdDoc = await createDocumentWithInitialState(this.reactorClient, {
4118
4138
  documentType,
4119
4139
  parentIdOrSlug,
4120
4140
  name,
@@ -4128,7 +4148,7 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
4128
4148
  name
4129
4149
  }, this.graphqlManager.reactorDriveClient, this.viewSubject(ctx));
4130
4150
  if (ctx.user?.address && createdDoc?.id) await this.documentPermissionService?.initializeDocumentProtection(createdDoc.id, ctx.user.address, this.authorizationService.config.defaultProtection);
4131
- if (!initialState && !preferredEditor && name && createdDoc.name !== name) return toGqlPhDocument(await this.reactorClient.execute(createdDoc.id, "main", [setName(name)], void 0, this.viewSubject(ctx)));
4151
+ if (!withHeader && name && createdDoc.name !== name) return toGqlPhDocument(await this.reactorClient.execute(createdDoc.id, "main", [setName(name)], void 0, this.viewSubject(ctx)));
4132
4152
  return createdDoc;
4133
4153
  },
4134
4154
  createEmptyDocument: async (_, args, ctx) => {
@@ -7913,10 +7933,10 @@ const ADMIN_USERS = getAdminUsers();
7913
7933
  //#endregion
7914
7934
  //#region src/graphql/system/version.ts
7915
7935
  function getVersion() {
7916
- return "6.2.3-dev.70";
7936
+ return "6.2.3-dev.71";
7917
7937
  }
7918
7938
  function getGitHash() {
7919
- return "0be5fa0275397a32da4f8ad8cd9a42117bcac879";
7939
+ return "5533a2c21ac67b89746c6ed26c033ae99659e131";
7920
7940
  }
7921
7941
  function getGitUrl() {
7922
7942
  return buildTreeUrl(getGitHash());
@@ -11124,4 +11144,4 @@ var PackageManagementService = class {
11124
11144
  export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DEFAULT_INSPECTION_THROTTLE, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentModelSchemaCache, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentRelationshipFieldsFragmentDoc, EvaluateActionsDocument, ExecuteBatchDocument, ExecutionJobInputSchema, FindDocumentsDocument, ForbiddenError, GetCreateDefaultsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentServedDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InspectionSubgraph, InspectionThrottle, InspectionThrottledError, InvalidNamespaceError, JobChangesDocument, JobInfoFieldsFragmentDoc, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SubgraphTypeCollisionError, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WS_CLOSE_REASON_CREDENTIAL_REVOKED, WebhookService, assembleSubgraphTypeDefs, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, baseDocumentModels, buildDocumentModelSchema, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createCredentialInvalidator, createGatewayAdapter, createHttpAdapter, createInspectionResolvers, createMergedSchema, createReactorGraphQLClient, createReactorInspectionSource, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, definedNonNullAnySchema, documentModelSubgraphTypes, driveIdFromUrl, extractSubgraphs, extractSubgraphsFromModule, findSubgraphTypeCollisions, generateDocumentModelSchema, generatedTypesOf, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelSubgraphName, getDocumentModelTypeDefs, getExplorerPrefix, getGeneratedDocumentModelTypes, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, hasOperationSchemas, initAnalyticsStoreSql, initializeAndStartAPI, inspectionTypeDefs, isDefinedNonNullAny, isExpectedLoaderMiss, isListedAdmin, isPostgresConnectionString, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, redactHeaders, renderGraphqlPlayground, reportFailure, reservedTypeNames, reservedTypeNamesTaken, resolveCredentialCacheTtlMs, resolvePackageName, resolveRenownConfig, runDetached, typeDefinitionNames, verifyWebhook };
11125
11145
 
11126
11146
  //# sourceMappingURL=index.mjs.map
11127
- //# debugId=15ac44c0-1e9f-5725-b675-7e5e00ca51a4
11147
+ //# debugId=c8953112-fd9f-50d0-b2fd-b0854a6626b6