@webiny/api-record-locking 6.6.0-alpha.0 → 6.6.0-alpha.1
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { FeatureFlags } from "@webiny/api-core/features/featureFlags/abstractions.js";
|
|
2
3
|
import { RecordLockingModel } from "./domain/RecordLockingModel.js";
|
|
3
4
|
import { RecordLockingAppConfig } from "./domain/RecordLockingAppConfig.js";
|
|
4
5
|
import { getTimeout } from "./utils/getTimeout.js";
|
|
@@ -6,6 +7,7 @@ import { RecordLockingContextualSchema } from "./graphql/RecordLockingContextual
|
|
|
6
7
|
const RecordLockingAppFeature = createFeature({
|
|
7
8
|
name: "RecordLockingApp",
|
|
8
9
|
register (container, params) {
|
|
10
|
+
if (!container.resolve(FeatureFlags).get().isEnabled("recordLocking")) return;
|
|
9
11
|
container.register(RecordLockingModel);
|
|
10
12
|
container.registerInstance(RecordLockingAppConfig, {
|
|
11
13
|
timeout: getTimeout(params?.timeout)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordLockingAppFeature.js","sources":["../src/RecordLockingAppFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport { RecordLockingModel } from \"~/domain/RecordLockingModel.js\";\nimport { RecordLockingAppConfig } from \"~/domain/RecordLockingAppConfig.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingContextualSchema } from \"~/graphql/RecordLockingContextualSchema.js\";\n\nexport interface IRecordLockingAppFeatureParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nexport const RecordLockingAppFeature = createFeature<IRecordLockingAppFeatureParams>({\n name: \"RecordLockingApp\",\n register(container: Container, params: IRecordLockingAppFeatureParams) {\n container.register(RecordLockingModel);\n container.registerInstance(RecordLockingAppConfig, {\n timeout: getTimeout(params?.timeout)\n });\n container.register(RecordLockingContextualSchema);\n }\n});\n"],"names":["RecordLockingAppFeature","createFeature","container","params","RecordLockingModel","RecordLockingAppConfig","getTimeout","RecordLockingContextualSchema"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RecordLockingAppFeature.js","sources":["../src/RecordLockingAppFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/RecordLockingModel.js\";\nimport { RecordLockingAppConfig } from \"~/domain/RecordLockingAppConfig.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingContextualSchema } from \"~/graphql/RecordLockingContextualSchema.js\";\n\nexport interface IRecordLockingAppFeatureParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nexport const RecordLockingAppFeature = createFeature<IRecordLockingAppFeatureParams>({\n name: \"RecordLockingApp\",\n register(container: Container, params: IRecordLockingAppFeatureParams) {\n // Record locking is license-gated — check at register time (license is fresh pre-register)\n // so nothing wires up without the entitlement.\n if (!container.resolve(FeatureFlags).get().isEnabled(\"recordLocking\")) {\n return;\n }\n\n container.register(RecordLockingModel);\n container.registerInstance(RecordLockingAppConfig, {\n timeout: getTimeout(params?.timeout)\n });\n container.register(RecordLockingContextualSchema);\n }\n});\n"],"names":["RecordLockingAppFeature","createFeature","container","params","FeatureFlags","RecordLockingModel","RecordLockingAppConfig","getTimeout","RecordLockingContextualSchema"],"mappings":";;;;;;AAcO,MAAMA,0BAA0BC,cAA8C;IACjF,MAAM;IACN,UAASC,SAAoB,EAAEC,MAAsC;QAGjE,IAAI,CAACD,UAAU,OAAO,CAACE,cAAc,GAAG,GAAG,SAAS,CAAC,kBACjD;QAGJF,UAAU,QAAQ,CAACG;QACnBH,UAAU,gBAAgB,CAACI,wBAAwB;YAC/C,SAASC,WAAWJ,QAAQ;QAChC;QACAD,UAAU,QAAQ,CAACM;IACvB;AACJ"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { GraphQLSchema } from "graphql";
|
|
2
2
|
import type { IGraphQLContextualSchema } from "@webiny/api-graphql";
|
|
3
|
-
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
4
3
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
4
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
5
|
import { type IRecordLockingAppConfig } from "../domain/RecordLockingAppConfig.js";
|
|
7
6
|
declare class RecordLockingContextualSchemaImpl implements IGraphQLContextualSchema {
|
|
8
|
-
private wcp;
|
|
9
7
|
private tenantCtx;
|
|
10
8
|
private identityCtx;
|
|
11
9
|
private config;
|
|
12
|
-
constructor(
|
|
10
|
+
constructor(tenantCtx: TenantContext.Interface, identityCtx: IdentityContext.Interface, config: IRecordLockingAppConfig);
|
|
13
11
|
build(ctx: Record<string, any>): Promise<GraphQLSchema>;
|
|
14
12
|
}
|
|
15
13
|
export declare const RecordLockingContextualSchema: typeof RecordLockingContextualSchemaImpl & {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
2
2
|
import { mergeResolvers } from "@graphql-tools/merge";
|
|
3
3
|
import { GraphQLContextualSchema } from "@webiny/api-graphql";
|
|
4
|
-
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
5
4
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
6
5
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
7
6
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
@@ -13,14 +12,13 @@ import { RecordLockingAppConfig } from "../domain/RecordLockingAppConfig.js";
|
|
|
13
12
|
import { RecordLockingFeature } from "../features/RecordLockingFeature.js";
|
|
14
13
|
import { createGraphQLSchema } from "./schema.js";
|
|
15
14
|
class RecordLockingContextualSchemaImpl {
|
|
16
|
-
constructor(
|
|
17
|
-
this.wcp = wcp;
|
|
15
|
+
constructor(tenantCtx, identityCtx, config){
|
|
18
16
|
this.tenantCtx = tenantCtx;
|
|
19
17
|
this.identityCtx = identityCtx;
|
|
20
18
|
this.config = config;
|
|
21
19
|
}
|
|
22
20
|
async build(ctx) {
|
|
23
|
-
if (!this.
|
|
21
|
+
if (!this.tenantCtx.getTenant()) return makeExecutableSchema({
|
|
24
22
|
typeDefs: "type Query\ntype Mutation",
|
|
25
23
|
assumeValidSDL: true
|
|
26
24
|
});
|
|
@@ -66,7 +64,6 @@ class RecordLockingContextualSchemaImpl {
|
|
|
66
64
|
const RecordLockingContextualSchema = GraphQLContextualSchema.createImplementation({
|
|
67
65
|
implementation: RecordLockingContextualSchemaImpl,
|
|
68
66
|
dependencies: [
|
|
69
|
-
WcpContext,
|
|
70
67
|
TenantContext,
|
|
71
68
|
IdentityContext,
|
|
72
69
|
RecordLockingAppConfig
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/RecordLockingContextualSchema.js","sources":["../../src/graphql/RecordLockingContextualSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { GraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport type { IGraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport {
|
|
1
|
+
{"version":3,"file":"graphql/RecordLockingContextualSchema.js","sources":["../../src/graphql/RecordLockingContextualSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { GraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport type { IGraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { createBaseContentSchema } from \"@webiny/api-headless-cms/graphql/schema/baseContentSchema.js\";\nimport { RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport {\n RecordLockingAppConfig,\n type IRecordLockingAppConfig\n} from \"~/domain/RecordLockingAppConfig.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\n\nclass RecordLockingContextualSchemaImpl implements IGraphQLContextualSchema {\n constructor(\n private tenantCtx: TenantContext.Interface,\n private identityCtx: IdentityContext.Interface,\n private config: IRecordLockingAppConfig\n ) {}\n\n async build(ctx: Record<string, any>): Promise<GraphQLSchema> {\n // Only registered when recordLocking is licensed (RecordLockingAppFeature gates on the flag),\n // so here we only fall back to an empty schema until the tenant is known.\n if (!this.tenantCtx.getTenant()) {\n return makeExecutableSchema({\n typeDefs: \"type Query\\ntype Mutation\",\n assumeValidSDL: true\n });\n }\n\n const container = ctx.container as Container;\n\n // Resolve the CMS use-cases lazily here (at build/request time) rather than as\n // constructor dependencies. They depend on AccessControl/CmsContext, which the CMS\n // initializer only registers during its own build() — so injecting them eagerly would\n // fail when the engine constructs all contextual schemas before any build() has run.\n const getModel = container.resolve(GetModelUseCase);\n const listModels = container.resolve(ListModelsUseCase);\n const fieldRegistry = container.resolve(CmsModelFieldToGraphQLRegistry);\n\n const [model, publicModels] = await this.identityCtx.withoutAuthorization(async () => {\n const [modelResult, publicModelsResult] = await Promise.all([\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n listModels.execute({ includePrivate: false })\n ]);\n\n return [modelResult.value, publicModelsResult.value];\n });\n\n RecordLockingFeature.register(container, {\n timeout: this.config.timeout,\n model\n });\n\n const plugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldRegistry\n });\n\n // The generated record-locking model schema references CMS base scalars (DateTime, JSON,\n // etc.). Include createBaseContentSchema() — which declares those scalars and their\n // resolvers — exactly as the normal CMS schema build (buildSchemaPlugins) does, so this\n // standalone schema is self-contained and valid before it is merged by the engine.\n const baseContent = createBaseContentSchema();\n\n return makeExecutableSchema({\n typeDefs: [baseContent.schema.typeDefs as string, plugin.schema.typeDefs as string],\n resolvers: mergeResolvers([\n baseContent.schema.resolvers as any,\n plugin.schema.resolvers as any\n ]),\n inheritResolversFromInterfaces: true\n });\n }\n}\n\nexport const RecordLockingContextualSchema = GraphQLContextualSchema.createImplementation({\n implementation: RecordLockingContextualSchemaImpl,\n dependencies: [TenantContext, IdentityContext, RecordLockingAppConfig]\n});\n"],"names":["RecordLockingContextualSchemaImpl","tenantCtx","identityCtx","config","ctx","makeExecutableSchema","container","getModel","GetModelUseCase","listModels","ListModelsUseCase","fieldRegistry","CmsModelFieldToGraphQLRegistry","model","publicModels","modelResult","publicModelsResult","Promise","RECORD_LOCKING_MODEL_ID","RecordLockingFeature","plugin","createGraphQLSchema","baseContent","createBaseContentSchema","mergeResolvers","RecordLockingContextualSchema","GraphQLContextualSchema","TenantContext","IdentityContext","RecordLockingAppConfig"],"mappings":";;;;;;;;;;;;;AAoBA,MAAMA;IACF,YACYC,SAAkC,EAClCC,WAAsC,EACtCC,MAA+B,CACzC;aAHUF,SAAS,GAATA;aACAC,WAAW,GAAXA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,MAAMC,GAAwB,EAA0B;QAG1D,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,IACzB,OAAOC,qBAAqB;YACxB,UAAU;YACV,gBAAgB;QACpB;QAGJ,MAAMC,YAAYF,IAAI,SAAS;QAM/B,MAAMG,WAAWD,UAAU,OAAO,CAACE;QACnC,MAAMC,aAAaH,UAAU,OAAO,CAACI;QACrC,MAAMC,gBAAgBL,UAAU,OAAO,CAACM;QAExC,MAAM,CAACC,OAAOC,aAAa,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YACtE,MAAM,CAACC,aAAaC,mBAAmB,GAAG,MAAMC,QAAQ,GAAG,CAAC;gBACxDV,SAAS,OAAO,CAACW;gBACjBT,WAAW,OAAO,CAAC;oBAAE,gBAAgB;gBAAM;aAC9C;YAED,OAAO;gBAACM,YAAY,KAAK;gBAAEC,mBAAmB,KAAK;aAAC;QACxD;QAEAG,qBAAqB,QAAQ,CAACb,WAAW;YACrC,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5BO;QACJ;QAEA,MAAMO,SAAS,MAAMC,oBAAoB;YACrCR;YACA,QAAQC;YACRH;QACJ;QAMA,MAAMW,cAAcC;QAEpB,OAAOlB,qBAAqB;YACxB,UAAU;gBAACiB,YAAY,MAAM,CAAC,QAAQ;gBAAYF,OAAO,MAAM,CAAC,QAAQ;aAAW;YACnF,WAAWI,eAAe;gBACtBF,YAAY,MAAM,CAAC,SAAS;gBAC5BF,OAAO,MAAM,CAAC,SAAS;aAC1B;YACD,gCAAgC;QACpC;IACJ;AACJ;AAEO,MAAMK,gCAAgCC,wBAAwB,oBAAoB,CAAC;IACtF,gBAAgB1B;IAChB,cAAc;QAAC2B;QAAeC;QAAiBC;KAAuB;AAC1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-record-locking",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -16,29 +16,28 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graphql-tools/merge": "9.2.
|
|
20
|
-
"@graphql-tools/schema": "10.0
|
|
21
|
-
"@webiny/api": "6.6.0-alpha.
|
|
22
|
-
"@webiny/api-graphql": "6.6.0-alpha.
|
|
23
|
-
"@webiny/api-headless-cms": "6.6.0-alpha.
|
|
24
|
-
"@webiny/api-websockets": "6.6.0-alpha.
|
|
25
|
-
"@webiny/feature": "6.6.0-alpha.
|
|
26
|
-
"@webiny/handler": "6.6.0-alpha.
|
|
27
|
-
"@webiny/utils": "6.6.0-alpha.
|
|
19
|
+
"@graphql-tools/merge": "9.2.3",
|
|
20
|
+
"@graphql-tools/schema": "10.1.0",
|
|
21
|
+
"@webiny/api": "6.6.0-alpha.1",
|
|
22
|
+
"@webiny/api-graphql": "6.6.0-alpha.1",
|
|
23
|
+
"@webiny/api-headless-cms": "6.6.0-alpha.1",
|
|
24
|
+
"@webiny/api-websockets": "6.6.0-alpha.1",
|
|
25
|
+
"@webiny/feature": "6.6.0-alpha.1",
|
|
26
|
+
"@webiny/handler": "6.6.0-alpha.1",
|
|
27
|
+
"@webiny/utils": "6.6.0-alpha.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@webiny/api-core": "6.6.0-alpha.
|
|
31
|
-
"@webiny/api-core-testing": "6.6.0-alpha.
|
|
32
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
33
|
-
"@webiny/di": "1.0
|
|
34
|
-
"@webiny/event-handler-core": "6.6.0-alpha.
|
|
35
|
-
"@webiny/
|
|
36
|
-
"@webiny/wcp": "6.6.0-alpha.0",
|
|
30
|
+
"@webiny/api-core": "6.6.0-alpha.1",
|
|
31
|
+
"@webiny/api-core-testing": "6.6.0-alpha.1",
|
|
32
|
+
"@webiny/build-tools": "6.6.0-alpha.1",
|
|
33
|
+
"@webiny/di": "1.1.0",
|
|
34
|
+
"@webiny/event-handler-core": "6.6.0-alpha.1",
|
|
35
|
+
"@webiny/wcp": "6.6.0-alpha.1",
|
|
37
36
|
"graphql": "16.14.2",
|
|
38
37
|
"rimraf": "6.1.3",
|
|
39
38
|
"type-fest": "5.8.0",
|
|
40
39
|
"typescript": "7.0.2",
|
|
41
|
-
"vitest": "4.1.
|
|
40
|
+
"vitest": "4.1.11"
|
|
42
41
|
},
|
|
43
42
|
"publishConfig": {
|
|
44
43
|
"access": "public"
|