@bluepic/embed 0.4.0-next.187 → 0.4.0-next.189

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Credentials for the GATED brand-portal asset routes
3
+ * (`/api/public/campaigns/:uid/assets/:assetId/{download|preview|document}`).
4
+ *
5
+ * A protected campaign is unlocked either with its password or by signing in;
6
+ * the config and serial fetches already carry that proof, but the asset bytes
7
+ * are requested separately — by a `fetch()` (download, viewer parsing) or by a
8
+ * media element's `src` (audio, video, image), which cannot carry headers at
9
+ * all. This module is the ONE place that knows how to attach the proof to
10
+ * either kind of request, so the two can never drift apart:
11
+ *
12
+ * - `assetRequestHeaders` → `X-Bluepic-Password` / `Authorization: Bearer …`
13
+ * - `withAssetAuthQuery` → `?password=…` / `?access_token=…`
14
+ *
15
+ * Prefer the headers wherever a `fetch()` is used; the query form exists only
16
+ * for `src` attributes. An empty auth object leaves headers and URLs untouched,
17
+ * so a public campaign behaves exactly as before.
18
+ */
19
+ export type AssetAuth = {
20
+ /** The campaign password the visitor unlocked with, if any. */
21
+ password?: string;
22
+ /** The signed-in visitor's Auth0 access token, if any. */
23
+ accessToken?: string;
24
+ };
25
+ /** Query parameter names the API accepts for media `src` URLs. */
26
+ export declare const ASSET_AUTH_QUERY_PASSWORD = "password";
27
+ export declare const ASSET_AUTH_QUERY_ACCESS_TOKEN = "access_token";
28
+ /** Headers for a `fetch()` of gated asset bytes. `{}` when nothing to attach. */
29
+ export declare function assetRequestHeaders(auth?: AssetAuth | null): Record<string, string>;
30
+ /**
31
+ * The same proof as query parameters, for `<img>`/`<video>`/`<audio>` sources
32
+ * that cannot carry headers. Returns `url` unchanged when there is nothing to
33
+ * attach. Existing query parameters (and a hash) are preserved.
34
+ */
35
+ export declare function withAssetAuthQuery(url: string, auth?: AssetAuth | null): string;
@@ -38,6 +38,13 @@ export interface BatchExportProgress {
38
38
  current: number;
39
39
  /** 1-based index of the row being rendered. */
40
40
  currentIndex: number;
41
+ /** Rows that threw (rendering or consuming) and were skipped. */
42
+ failed: number;
43
+ }
44
+ /** A row that did not make it into the output. `index` is 0-based (row 1 is index 0). */
45
+ export interface BatchFailedRow {
46
+ index: number;
47
+ message: string;
41
48
  }
42
49
  export interface BatchFileExportResult {
43
50
  /** One blob per exported file (a multi-frame template yields several per row). */
@@ -51,6 +58,11 @@ export interface BatchFileExportResult {
51
58
  fileName: string;
52
59
  };
53
60
  cancelled: boolean;
61
+ /**
62
+ * Rows missing from `output` because they threw. Successful rows were still
63
+ * consumed (charged) and packed; a failed row was never consumed.
64
+ */
65
+ failedRows: BatchFailedRow[];
54
66
  }
55
67
  /** Image rows render four at a time, videos strictly one after the other (decision 2026-09-02). */
56
68
  export declare const BATCH_IMAGE_CONCURRENCY = 4;
@@ -64,8 +76,10 @@ export declare function batchFileBaseNames(rows: BatchRow[], naming: BatchNaming
64
76
  *
65
77
  * Images go through the campaign render endpoint (which does not charge — the
66
78
  * per-row `consumeOutput` does), videos through the video render service.
67
- * Rows are rendered in order; a failed row aborts the export with its error
68
- * so nothing half-billed slips through silently.
79
+ * Rows are rendered in order and isolated from each other: a row that throws
80
+ * is recorded in `failedRows` (never consumed, never packed) and the rest
81
+ * carry on, so one bad row cannot discard the already-charged good ones. Only
82
+ * when every row failed is there nothing to hand out, and the export throws.
69
83
  */
70
84
  export declare function exportBatchFiles(rows: BatchRow[], format: BatchFileFormat, naming: BatchNaming, ctx: BatchFileExportContext, onProgress?: (progress: BatchExportProgress) => void): Promise<BatchFileExportResult>;
71
85
  /** One file stays a file; several become a zip named after the template. */
@@ -1,4 +1,4 @@
1
- import { FieldsBridge, Render, Studio, Template } from '@bluepic/types';
1
+ import { BillingV3, FieldsBridge, Render, Studio, Template } from '@bluepic/types';
2
2
  import { Ref } from 'vue';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import BxLiveTemplate from '../components/TemplateEditor/BxLiveTemplate.vue';
@@ -97,11 +97,18 @@ svgLoadWaitDelay?: Ref<number | undefined>): {
97
97
  rendering: Ref<boolean, boolean>;
98
98
  videoRenderingProgress: Ref<number | undefined, number | undefined>;
99
99
  };
100
+ /**
101
+ * Report ONE delivered output to the server.
102
+ *
103
+ * The SDK names the surface (`usage`) and describes what it produced
104
+ * (`assets`) — it never sends, and never learns, a price. The rate table lives
105
+ * server-side in `@bluepic/types` (`BillingV3.calculateCenticreditConsumption`).
106
+ */
100
107
  export declare function consumeCredits(apiBaseUrl: string, env: 'dev' | 'prod', campaignId: number, templateId: string, sessionState: string, billingKey: number,
101
- /** Which rate to bill at. Omitted = `conversion`, the single-export rate. */
102
- action?: Studio.ConsumeRenderCreditsAction,
103
- /** Units of that action1 for anything but a video, which bills in video credit units. */
104
- amount?: number): Promise<void>;
108
+ /** Which surface produced this. Omitted = a single editor export. */
109
+ usage?: Studio.ConsumeRenderCreditsUsage,
110
+ /** One entry per delivered file an array of one for a single export. */
111
+ assets?: BillingV3.BillableUsageAsset[]): Promise<void>;
105
112
  export declare function hasMobileShareCapability(files: File[]): boolean;
106
113
  export declare function blobsToShareFiles(files: Blob[], baseName: string): File[];
107
114
  export declare function performDownload(files: Blob[], baseName: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluepic/embed",
3
- "version": "0.4.0-next.187",
3
+ "version": "0.4.0-next.189",
4
4
  "description": "Bluepic embed sdk",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@auth0/auth0-vue": "^2.4.0",
49
- "@bluepic/types": "^0.8.70",
49
+ "@bluepic/types": "^0.8.75",
50
50
  "@hono/zod-openapi": "^1.1.4",
51
51
  "@types/css": "^0.0.38",
52
52
  "@types/downloadjs": "^1.4.6",