@forumone/throughline-publishing 0.2.0 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @forumone/throughline-publishing
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [a4b5108]
8
+ - @forumone/throughline-core@0.2.1
9
+
10
+ ## 0.2.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 3ef6f6a: The pipeline's `approvalStep` now falls back to looking up an approval resolver on the Payload instance under `Symbol.for('@forumone/throughline/approvals-resolver')` when no resolver is supplied via `publishingPlugin`'s `options.approvalResolver`. The `@forumone/throughline-approvals` plugin attaches its resolver under that symbol automatically, so adding approvals to a config no longer requires re-wiring the publishing plugin's options. An explicit `options.approvalResolver` still takes precedence when you need to override.
15
+
3
16
  ## 0.2.0
4
17
 
5
18
  ### Minor Changes
@@ -1,11 +1,21 @@
1
1
  import type { PipelineStep } from '../types.js';
2
+ /**
3
+ * Symbol the approvals plugin attaches its resolver under. Publishing's
4
+ * approval step looks here when no resolver is supplied via options, which
5
+ * lets clients add the approvals plugin without re-wiring publishing's
6
+ * config. Keep in sync with the matching constant in the approvals package.
7
+ */
8
+ export declare const APPROVALS_RESOLVER_SYMBOL: unique symbol;
2
9
  /**
3
10
  * Gates publish on a granted approval when the document's policy demands
4
- * one. Fails closed: if `policy.requiresApproval` is true but no
5
- * `approvalResolver` is configured, the step fails rather than silently
6
- * letting the publish proceed without approval. The Approvals Server
7
- * (C7) provides the resolver implementation; until it ships, clients
8
- * who want approvals must wire their own.
11
+ * one. Fails closed: if `policy.requiresApproval` is true but no resolver
12
+ * is available (neither in options nor attached via the approvals plugin),
13
+ * the step blocks the publish.
14
+ *
15
+ * Resolution order:
16
+ * 1. `options.approvalResolver` (explicit wiring)
17
+ * 2. The resolver attached on the Payload instance via
18
+ * `APPROVALS_RESOLVER_SYMBOL` by the approvals plugin
9
19
  */
10
20
  export declare const approvalStep: PipelineStep;
11
21
  //# sourceMappingURL=approval.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/approval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,YAmC1B,CAAA"}
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../src/pipeline/steps/approval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,eAErC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,YAoC1B,CAAA"}
@@ -1,25 +1,36 @@
1
+ /**
2
+ * Symbol the approvals plugin attaches its resolver under. Publishing's
3
+ * approval step looks here when no resolver is supplied via options, which
4
+ * lets clients add the approvals plugin without re-wiring publishing's
5
+ * config. Keep in sync with the matching constant in the approvals package.
6
+ */
7
+ export const APPROVALS_RESOLVER_SYMBOL = Symbol.for('@forumone/throughline/approvals-resolver');
1
8
  /**
2
9
  * Gates publish on a granted approval when the document's policy demands
3
- * one. Fails closed: if `policy.requiresApproval` is true but no
4
- * `approvalResolver` is configured, the step fails rather than silently
5
- * letting the publish proceed without approval. The Approvals Server
6
- * (C7) provides the resolver implementation; until it ships, clients
7
- * who want approvals must wire their own.
10
+ * one. Fails closed: if `policy.requiresApproval` is true but no resolver
11
+ * is available (neither in options nor attached via the approvals plugin),
12
+ * the step blocks the publish.
13
+ *
14
+ * Resolution order:
15
+ * 1. `options.approvalResolver` (explicit wiring)
16
+ * 2. The resolver attached on the Payload instance via
17
+ * `APPROVALS_RESOLVER_SYMBOL` by the approvals plugin
8
18
  */
9
19
  export const approvalStep = async (ctx) => {
10
20
  const policy = ctx.document[ctx.collection.policyField];
11
21
  if (!policy?.['requiresApproval'])
12
22
  return { pass: true };
13
- if (!ctx.options.approvalResolver) {
23
+ const resolver = ctx.options.approvalResolver ?? lookupResolverOnPayload(ctx.payload);
24
+ if (!resolver) {
14
25
  return {
15
26
  pass: false,
16
27
  code: 'approval-resolver-missing',
17
28
  reason: 'Document requires approval but no approval resolver is configured',
18
- suggestion: 'Add the approvalsPlugin to your Payload config and pass its resolver to publishingPlugin.approvalResolver.',
29
+ suggestion: 'Register approvalsPlugin in your Payload config (it attaches the resolver automatically) or pass an explicit `approvalResolver` to publishingPlugin.',
19
30
  };
20
31
  }
21
32
  const versionId = String(ctx.document['updatedAt'] ?? ctx.documentId);
22
- const approval = await ctx.options.approvalResolver.getActiveApproval(ctx.collection.slug, ctx.documentId, versionId);
33
+ const approval = await resolver.getActiveApproval(ctx.collection.slug, ctx.documentId, versionId);
23
34
  if (!approval) {
24
35
  return {
25
36
  pass: false,
@@ -30,4 +41,8 @@ export const approvalStep = async (ctx) => {
30
41
  }
31
42
  return { pass: true };
32
43
  };
44
+ function lookupResolverOnPayload(payload) {
45
+ const value = payload[APPROVALS_RESOLVER_SYMBOL];
46
+ return typeof value === 'object' && value !== null ? value : undefined;
47
+ }
33
48
  //# sourceMappingURL=approval.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../../src/pipeline/steps/approval.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAiB,KAAK,EAAE,GAAG,EAAE,EAAE;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAEzC,CAAA;IACb,IAAI,CAAC,MAAM,EAAE,CAAC,kBAAkB,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAExD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAClC,OAA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;QACd,OAAO;YACL,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,2BAA2B;YACjC,MAAM,EAAE,mEAAmE;YAC3E,UAAU,EACR,sJAAsJ;SACzJ,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAA;IACrE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAC/C,GAAG,CAAC,UAAU,CAAC,IAAI,EACnB,GAAG,CAAC,UAAU,EACd,SAAS,CACV,CAAA;IAED,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,mBAAmB;YACzB,MAAM,EACJ,wFAAwF;YAC1F,UAAU,EACR,mFAAmF;SACtF,CAAA;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AACvB,CAAC,CAAA;AAED,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,KAAK,GAAI,OAAmC,CAAC,yBAAyB,CAAC,CAAA;IAC7E,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,KAA0B,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forumone/throughline-publishing",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Policy-gated publishing server for Throughline. Wraps Payload's update operation with composition, accessibility, required-field, embargo, and approval gating.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "zod": "^3.23.0",
48
- "@forumone/throughline-core": "0.2.0",
48
+ "@forumone/throughline-core": "0.2.1",
49
49
  "@forumone/throughline-plugin-contract": "0.0.0"
50
50
  },
51
51
  "devDependencies": {