@powerformer/prism-client 0.5.1 → 0.6.0

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/build-info.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@powerformer/prism-client",
3
- "version": "0.5.1",
4
- "gitCommit": "417ad02241680267e0725981a62364d77ec22358",
5
- "sourceSha256": "e695ed7f97de8bb04c3749d98dd73a39741505cc71bc6d7e1d25abba0fdab266",
3
+ "version": "0.6.0",
4
+ "gitCommit": "e17454fe9ca4694c7898e91264af4b8f3a23f02c",
5
+ "sourceSha256": "737da051a673a2bc1037ec3577a83519beaf69b14ecf500ac018d3cb98d913ba",
6
6
  "contentContract": "app/contracts",
7
- "contentContractSha256": "6be54897fa480783d06fa0ccd8234f774f086975ea6f28402177bf69a514af18"
7
+ "contentContractSha256": "933ed061701bdfb2d31f55a582dd8b8d329fbd9d6db25500ba9ed2126f1aa002"
8
8
  }
@@ -15187,7 +15187,8 @@ function date4(params) {
15187
15187
  }
15188
15188
 
15189
15189
  // app/contracts/resource-manifest.ts
15190
- var RESOURCE_CDN_ORIGIN = "https://r.open-design.ai", MANIFEST_PROTOCOL = "v1";
15190
+ var RESOURCE_CDN_ORIGIN = "https://r.open-design.ai", RESOURCE_DEV_CDN_ORIGIN = "https://r.powerformer.net", RESOURCE_INTERNAL_CDN_ORIGIN = "https://r-internal.powerformer.net", MANIFEST_PROTOCOL = "v1";
15191
+ var resourceVisibilitySchema = external_exports.enum(["public", "internal"]);
15191
15192
  var resourceIdSchema = external_exports.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/), channelNameSchema = external_exports.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/), versionIdSchema = external_exports.string().regex(/^ver_[0-9a-f]{32}$/), semanticLabelSchema = external_exports.string().min(1).max(64), semanticVersionSchema = external_exports.string().max(64).regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?![\s\S])/, "Use SemVer, for example 1.2.3 or 1.2.3-rc.1"), versionAddressSchema = external_exports.string().min(1).max(512).regex(/^[A-Za-z0-9][A-Za-z0-9._+-]*(?![\s\S])/), sha256Schema = external_exports.string().regex(/^[0-9a-f]{64}$/);
15192
15193
  function encodeResourcePathSegment(segment) {
15193
15194
  return encodeURIComponent(segment);
@@ -15283,8 +15284,9 @@ function parseResourceMain(value) {
15283
15284
  return resourceMainSchema.parse(value);
15284
15285
  }
15285
15286
  var resourceUuidSchema = external_exports.uuid().refine((value) => value === value.toLowerCase(), "Use a lowercase UUID");
15286
- function resourceDeliveryOrigin(environment) {
15287
- return resourceEnvironmentSchema.parse(environment) === "dev" ? "https://r.powerformer.net" : RESOURCE_CDN_ORIGIN;
15287
+ function resourceDeliveryOrigin(environment, visibility = "public") {
15288
+ let env = resourceEnvironmentSchema.parse(environment), vis = resourceVisibilitySchema.parse(visibility);
15289
+ return env === "dev" ? RESOURCE_DEV_CDN_ORIGIN : vis === "internal" ? RESOURCE_INTERNAL_CDN_ORIGIN : RESOURCE_CDN_ORIGIN;
15288
15290
  }
15289
15291
  function resourcePublicMainPath(id, channel) {
15290
15292
  return `/resources/${resourceUuidSchema.parse(id)}/channels/${channelNameSchema.parse(channel)}/main.json`;
@@ -15363,6 +15365,7 @@ function parseDeliveryManifest(value) {
15363
15365
  }
15364
15366
 
15365
15367
  export {
15368
+ resourceVisibilitySchema,
15366
15369
  channelNameSchema,
15367
15370
  versionAddressSchema,
15368
15371
  parseResourceManifest,
@@ -10,8 +10,9 @@ import {
10
10
  resourceUuidSchema,
11
11
  resourceVersionMainPath,
12
12
  resourceVersionManifestPath,
13
+ resourceVisibilitySchema,
13
14
  versionAddressSchema
14
- } from "./chunk-546JYWIC.js";
15
+ } from "./chunk-GGTUOAAF.js";
15
16
 
16
17
  // app/sdk/errors.ts
17
18
  var PrismError = class extends Error {
@@ -141,6 +142,7 @@ var ClientStore = class {
141
142
  if (!options || typeof options != "object") throw new PrismError("INVALID_CONFIG", "Prism options are required");
142
143
  this.options = {
143
144
  environment: checked(resourceEnvironmentSchema.parse, options.environment, "environment"),
145
+ visibility: checked(resourceVisibilitySchema.parse, options.visibility ?? "public", "visibility"),
144
146
  channel: checked(channelNameSchema.parse, options.channel ?? DEFAULT_EDITORIAL_CHANNEL, "channel"),
145
147
  timeoutMs: positive(options.timeoutMs ?? 8e3, "timeoutMs"),
146
148
  ...options.version === void 0 ? {} : { version: checked(versionAddressSchema.parse, options.version, "version") }
@@ -189,9 +191,9 @@ var ClientStore = class {
189
191
  timedOut = !0, controller.abort();
190
192
  }, this.options.timeoutMs);
191
193
  try {
192
- let path = this.options.version === void 0 ? resourcePublicMainPath(id, this.options.channel) : resourceVersionMainPath(id, this.options.channel, this.options.version), expectedVersionId = this.options.version === void 0 ? void 0 : previous?.main.versionId;
194
+ let path = this.options.version === void 0 ? resourcePublicMainPath(id, this.options.channel) : resourceVersionMainPath(id, this.options.channel, this.options.version), expectedVersionId = this.options.version === void 0 ? void 0 : previous?.main.versionId, origin = resourceDeliveryOrigin(this.options.environment, this.options.visibility);
193
195
  if (this.options.version !== void 0 && !expectedVersionId) {
194
- let response2 = await fetch(new URL(resourceVersionManifestPath(id, this.options.channel, this.options.version), resourceDeliveryOrigin(this.options.environment)), {
196
+ let response2 = await fetch(new URL(resourceVersionManifestPath(id, this.options.channel, this.options.version), origin), {
195
197
  method: "GET",
196
198
  cache: "no-store",
197
199
  credentials: "omit",
@@ -207,7 +209,7 @@ var ClientStore = class {
207
209
  throw new PrismError("IDENTITY_MISMATCH", `Version manifest identity does not match ${id}`, { resourceId: id });
208
210
  expectedVersionId = manifest.versionId;
209
211
  }
210
- let response = await fetch(new URL(path, resourceDeliveryOrigin(this.options.environment)), {
212
+ let response = await fetch(new URL(path, origin), {
211
213
  method: "GET",
212
214
  cache: "no-store",
213
215
  credentials: "omit",
@@ -2,7 +2,7 @@ import {
2
2
  Prism,
3
3
  PrismError,
4
4
  storeFor
5
- } from "./chunk-5F3SG6QX.js";
5
+ } from "./chunk-TG3NAWSK.js";
6
6
 
7
7
  // app/sdk/runtime.ts
8
8
  var key = /* @__PURE__ */ Symbol.for("@powerformer/prism-client/runtime/v1"), globalRegistry = globalThis, registry = globalRegistry[key] ??= /* @__PURE__ */ new Map();
@@ -1,13 +1,22 @@
1
1
  /** Prism delivery protocol. Browser-safe; server hashing lives in publication.ts. */
2
2
  import { z } from 'zod/v4';
3
- import type { ResourceEnvironment, ResourceManifest, ResourceManifestV2, ResourceMain } from './types.js';
4
- export type { ResourceEnvironment, ResourceManifest, ResourceManifestV2, ResourceMain } from './types.js';
3
+ import type { ResourceEnvironment, ResourceVisibility, ResourceManifest, ResourceManifestV2, ResourceMain } from './types.js';
4
+ export type { ResourceEnvironment, ResourceVisibility, ResourceManifest, ResourceManifestV2, ResourceMain } from './types.js';
5
5
  export declare const RESOURCE_CDN_ORIGIN = "https://r.open-design.ai";
6
+ export declare const RESOURCE_DEV_CDN_ORIGIN = "https://r.powerformer.net";
7
+ export declare const RESOURCE_INTERNAL_CDN_ORIGIN = "https://r-internal.powerformer.net";
6
8
  export declare const MANIFEST_PROTOCOL = "v1";
7
9
  export declare const DEFAULT_RESOURCE_CHANNEL = "stable";
8
10
  export declare const MANIFEST_CACHE_CONTROL = "no-store";
9
11
  export declare const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
12
+ export declare const PRIVATE_IMMUTABLE_CACHE_CONTROL = "private, max-age=31536000, immutable";
10
13
  export declare const REVALIDATE_CACHE_CONTROL = "no-cache";
14
+ export declare const resourceVisibilitySchema: z.ZodEnum<{
15
+ public: "public";
16
+ internal: "internal";
17
+ }>;
18
+ export declare function immutableCacheControl(visibility?: ResourceVisibility): string;
19
+ export declare function resourceFileDeliveryOrigin(visibility?: ResourceVisibility): string;
11
20
  export declare const resourceIdSchema: z.ZodString;
12
21
  export declare const channelNameSchema: z.ZodString;
13
22
  export declare const versionIdSchema: z.ZodString;
@@ -53,7 +62,7 @@ export declare function parseResourceMain(value: unknown): ResourceMain;
53
62
  export type { ResourceManifestV3, ResourceMainV2 } from './types.js';
54
63
  export declare const resourceUuidSchema: z.ZodUUID;
55
64
  export declare const slugSchema: z.ZodString;
56
- export declare function resourceDeliveryOrigin(environment: ResourceEnvironment): string;
65
+ export declare function resourceDeliveryOrigin(environment: ResourceEnvironment, visibility?: ResourceVisibility): string;
57
66
  export declare function resourcePublicMainPath(id: string, channel: string): string;
58
67
  export declare function resourcePublicManifestPath(id: string, channel: string): string;
59
68
  export declare function resourcePublicLocalePath(id: string, channel: string, locale: string): string;
@@ -71,5 +80,5 @@ export declare function parseResourceMainV2(value: unknown): import('./types.js'
71
80
  export declare function parseResourceManifestV4(value: unknown): import('./types.js').ResourceManifestV4;
72
81
  export declare function buildResourceManifestV4(input: Omit<import('./types.js').ResourceManifestV4, 'manifestVersion'>): import('./types.js').ResourceManifestV4;
73
82
  export declare function parseDeliveryManifest(value: unknown): import('./types.js').DeliveryManifest;
74
- /** Public paths use the selected environment bucket's custom domain. */
75
- export declare function resourceDeliveryUrl(path: string, environment: ResourceEnvironment, legacyOrigin?: string): string;
83
+ /** Public paths use the selected environment/visibility bucket's custom domain. */
84
+ export declare function resourceDeliveryUrl(path: string, environment: ResourceEnvironment, legacyOrigin?: string, visibility?: ResourceVisibility): string;
@@ -1,5 +1,6 @@
1
1
  /** Portable wire types. Validation is implemented once in resource-manifest.ts. */
2
2
  export type ResourceEnvironment = 'dev' | 'prod';
3
+ export type ResourceVisibility = 'public' | 'internal';
3
4
  export type JsonValue = null | boolean | number | string | JsonValue[] | {
4
5
  [key: string]: JsonValue;
5
6
  };
@@ -1,6 +1,7 @@
1
1
  import type { AstroIntegration } from 'astro';
2
2
  export interface PrismContentOptions {
3
3
  resources: readonly string[];
4
+ visibility?: import('./types.js').Visibility;
4
5
  channel?: string;
5
6
  version?: string;
6
7
  locale?: string;
package/dist/sdk/astro.js CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  getRuntime,
3
3
  releaseRuntime,
4
4
  runtimeSeeds
5
- } from "../chunk-PZLXS7XK.js";
5
+ } from "../chunk-VQYM3WCM.js";
6
6
  import {
7
7
  PrismError
8
- } from "../chunk-5F3SG6QX.js";
9
- import "../chunk-546JYWIC.js";
8
+ } from "../chunk-TG3NAWSK.js";
9
+ import "../chunk-GGTUOAAF.js";
10
10
 
11
11
  // app/sdk/astro.ts
12
12
  import { randomUUID } from "node:crypto";
@@ -23,6 +23,7 @@ function prismContent(options) {
23
23
  if (!(command === "preview" || command === "sync")) {
24
24
  clientOptions = {
25
25
  environment: command === "dev" ? "dev" : "prod",
26
+ ...options.visibility !== void 0 ? { visibility: options.visibility } : {},
26
27
  channel: options.channel,
27
28
  version: options.version,
28
29
  locale: options.locale,
@@ -16,7 +16,7 @@ import {
16
16
  resourceVersionLocalePath,
17
17
  resourceVersionMainPath,
18
18
  resourceVersionManifestPath
19
- } from "../chunk-546JYWIC.js";
19
+ } from "../chunk-GGTUOAAF.js";
20
20
 
21
21
  // app/sdk/contract.ts
22
22
  var parseResourceMain2 = parseResourceMain, parseResourceManifest2 = parseResourceManifest, parseResourceManifestV22 = parseResourceManifestV2, resourceMainPath2 = resourceMainPath, resourceEnvironmentManifestPath2 = resourceEnvironmentManifestPath, parseResourceMainV22 = parseResourceMainV2, parseResourceManifestV32 = parseResourceManifestV3, resourcePublicMainPath2 = resourcePublicMainPath, resourcePublicManifestPath2 = resourcePublicManifestPath, resourcePublicContentPath2 = resourcePublicContentPath, resourceDeliveryOrigin2 = resourceDeliveryOrigin, parseResourceManifestV42 = parseResourceManifestV4, parseDeliveryManifest2 = parseDeliveryManifest, resourceVersionMainPath2 = resourceVersionMainPath, resourceVersionManifestPath2 = resourceVersionManifestPath, resourceVersionLocalePath2 = resourceVersionLocalePath, resourcePublicLocalePath2 = resourcePublicLocalePath;
@@ -1,5 +1,5 @@
1
1
  export { Prism } from './client.js';
2
2
  export { PrismError } from './errors.js';
3
3
  export type { PrismErrorCode } from './errors.js';
4
- export type { PrismOptions, Environment, ResourceOptions, ResourceQuery, PublicationMeta, ResourceResult, ResourceBundleResult, DevServerOptions, DevServerHandle, DevUpdate, } from './types.js';
4
+ export type { PrismOptions, Environment, Visibility, ResourceOptions, ResourceQuery, PublicationMeta, ResourceResult, ResourceBundleResult, DevServerOptions, DevServerHandle, DevUpdate, } from './types.js';
5
5
  export type { ScopeRole, ResourceMembership } from '../contracts/access.js';
package/dist/sdk/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Prism,
3
3
  PrismError
4
- } from "../chunk-5F3SG6QX.js";
5
- import "../chunk-546JYWIC.js";
4
+ } from "../chunk-TG3NAWSK.js";
5
+ import "../chunk-GGTUOAAF.js";
6
6
  export {
7
7
  Prism,
8
8
  PrismError
@@ -2,9 +2,9 @@ import {
2
2
  getRuntime,
3
3
  releaseRuntime,
4
4
  runtimeSeeds
5
- } from "../chunk-PZLXS7XK.js";
6
- import "../chunk-5F3SG6QX.js";
7
- import "../chunk-546JYWIC.js";
5
+ } from "../chunk-VQYM3WCM.js";
6
+ import "../chunk-TG3NAWSK.js";
7
+ import "../chunk-GGTUOAAF.js";
8
8
  export {
9
9
  getRuntime,
10
10
  releaseRuntime,
@@ -1,6 +1,8 @@
1
1
  export type Environment = 'dev' | 'prod';
2
+ export type Visibility = 'public' | 'internal';
2
3
  export interface PrismOptions {
3
4
  environment: Environment;
5
+ visibility?: Visibility;
4
6
  channel?: string;
5
7
  /** Frozen URL address shown by Prism: SemVer for new Versions, saved alias for legacy Versions. */
6
8
  version?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerformer/prism-client",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Read published Prism multilingual content with shared caching and Astro development updates.",
6
6
  "license": "UNLICENSED",