@sprigr/apps-app-sdk 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +84 -1
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -589,6 +589,89 @@ interface SprigrFilesApi {
589
589
  key: string;
590
590
  }>;
591
591
  }
592
+ /**
593
+ * Platform document-engine bridge types (`env.SPRIGR.files.edit` / `.create`
594
+ * / `.job`). Canonical declaration: previously copied consumer-side into
595
+ * microsoft-365 and google-workspace to avoid a repo-wide vendor re-sync;
596
+ * upstreamed here once two live consumers shipped (m365 0.15/0.16,
597
+ * google-workspace 0.4).
598
+ */
599
+ /** Input to `env.SPRIGR.files.edit` (the platform surgical document edit bridge). */
600
+ interface SprigrFilesEditInput {
601
+ /** App-relative key of the source file already in app storage. */
602
+ file_key: string;
603
+ /** pdf runs the PyMuPDF ops engine (list_fields / fill_form / replace_text);
604
+ * docx/xlsx run python-docx / openpyxl; xer/pmxml/mspdi run the platform's
605
+ * pure-TS schedule engine in-worker (Primavera P6 / MS Project XML, no
606
+ * sandbox cold-start exposure). */
607
+ format: 'docx' | 'xlsx' | 'pdf' | 'xer' | 'pmxml' | 'mspdi';
608
+ operations: Array<Record<string, unknown>>;
609
+ output_filename?: string;
610
+ output_key?: string;
611
+ allow_lossy?: boolean;
612
+ /** Schedule formats only: write even when the FK-integrity gate finds
613
+ * errors (the validation result is still returned). */
614
+ skip_validation?: boolean;
615
+ /** Deterministic idempotency token: the platform persists the pipeline's
616
+ * terminal result under it, so a retry of the same logical edit after a
617
+ * dispatch timeout replays the finished result instead of re-running the
618
+ * engine. Filename-safe: ^[A-Za-z0-9_-]{8,128}$. */
619
+ job_token?: string;
620
+ }
621
+ /** Result from `env.SPRIGR.files.edit`. */
622
+ interface SprigrFilesEditResult {
623
+ ok: boolean;
624
+ out_file_key?: string;
625
+ size?: number;
626
+ operations_applied?: Array<Record<string, unknown>>;
627
+ failed_operations?: Array<Record<string, unknown>>;
628
+ warning?: string;
629
+ error?: string;
630
+ /** Schedule formats only: the FK-integrity result ({errorCount, warningCount, issues}). */
631
+ validation?: Record<string, unknown>;
632
+ /** Schedule formats only: one-line engine summary incl. matched counts. */
633
+ summary?: string;
634
+ }
635
+ /** Input to `env.SPRIGR.files.create` (build a NEW docx/xlsx from a spec). */
636
+ interface SprigrFilesCreateInput {
637
+ format: 'docx' | 'xlsx';
638
+ /** docx: content blocks (heading/paragraph/table/…). xlsx: sheet defs ({name, headers, rows, …}). */
639
+ spec: Array<Record<string, unknown>>;
640
+ properties?: Record<string, unknown>;
641
+ output_filename?: string;
642
+ output_key?: string;
643
+ /** Same idempotency semantics as SprigrFilesEditInput.job_token. */
644
+ job_token?: string;
645
+ }
646
+ /** Result from `env.SPRIGR.files.create`. */
647
+ interface SprigrFilesCreateResult {
648
+ ok: boolean;
649
+ out_file_key?: string;
650
+ size?: number;
651
+ error?: string;
652
+ }
653
+ /** Result from `env.SPRIGR.files.job` (read-only job-record status). */
654
+ interface SprigrFilesJobResult {
655
+ ok: boolean;
656
+ job_token: string;
657
+ status: 'not_found' | 'running' | 'done' | 'error';
658
+ /** True when the record is older than the platform's freshness windows
659
+ * (an orphaned `running` or an expired terminal record). */
660
+ stale?: boolean;
661
+ started_at?: number;
662
+ finished_at?: number;
663
+ http_status?: number;
664
+ /** The stored edit/create response body (terminal records only). */
665
+ result?: Record<string, unknown>;
666
+ }
667
+ /** The platform files bridge plus the document-engine methods. */
668
+ interface SprigrFilesApiWithEdit extends SprigrFilesApi {
669
+ edit(input: SprigrFilesEditInput): Promise<SprigrFilesEditResult>;
670
+ create(input: SprigrFilesCreateInput): Promise<SprigrFilesCreateResult>;
671
+ /** Optional: absent on wrapper builds older than the job-token surface;
672
+ * callers must feature-detect. */
673
+ job?(jobToken: string): Promise<SprigrFilesJobResult>;
674
+ }
592
675
  /** Narrow structural type for the per-install D1 binding. */
593
676
  interface D1Like {
594
677
  prepare(sql: string): D1PreparedStatementLike;
@@ -626,4 +709,4 @@ interface ExecutionContextLike {
626
709
  }
627
710
  type HandlerFn<TArgs, TResult> = (args: TArgs, env: Record<string, unknown>, ctx?: ExecutionContextLike) => Promise<TResult>;
628
711
 
629
- export { type Actor, type AppFileListItem, type AppFileUrlArgs, type AppFileUrlResult, type AppFilesEnv, type D1Like, type D1PreparedStatementLike, DEFAULT_MAX_FILE_BYTES, type EventArgs, type ExecutionContextLike, type FetchFileResult, type FetchWithRetryOptions, type GetAppFileResult, type HandlerFn, type MarketplaceEventEmitOpts, type MarketplaceEventSourceIntegration, type OAuthState, type PlatformHostEnv, type PutAppFileArgs, type PutAppFileResult, type PutAppFileStreamArgs, type ScheduleArgs, type SprigrDataApi, type SprigrDataSearchOpts, type SprigrDataSearchResult, type SprigrFilesApi, type WebhookArgs, actorKey, appFileUrl, base64ToBytes, buildMarketplaceWebhookUrl, bytesToBase64, constantTimeEqual, decodeState, deleteAppFile, encodeState, fetchFileAsBase64, fetchFileBytes, fetchWithRetry, getAppFile, hmacSha256Hex, listAppFiles, parseActor, putAppFile, putAppFileStream, randomHex, resolvePlatformWebhookBase };
712
+ export { type Actor, type AppFileListItem, type AppFileUrlArgs, type AppFileUrlResult, type AppFilesEnv, type D1Like, type D1PreparedStatementLike, DEFAULT_MAX_FILE_BYTES, type EventArgs, type ExecutionContextLike, type FetchFileResult, type FetchWithRetryOptions, type GetAppFileResult, type HandlerFn, type MarketplaceEventEmitOpts, type MarketplaceEventSourceIntegration, type OAuthState, type PlatformHostEnv, type PutAppFileArgs, type PutAppFileResult, type PutAppFileStreamArgs, type ScheduleArgs, type SprigrDataApi, type SprigrDataSearchOpts, type SprigrDataSearchResult, type SprigrFilesApi, type SprigrFilesApiWithEdit, type SprigrFilesCreateInput, type SprigrFilesCreateResult, type SprigrFilesEditInput, type SprigrFilesEditResult, type SprigrFilesJobResult, type WebhookArgs, actorKey, appFileUrl, base64ToBytes, buildMarketplaceWebhookUrl, bytesToBase64, constantTimeEqual, decodeState, deleteAppFile, encodeState, fetchFileAsBase64, fetchFileBytes, fetchWithRetry, getAppFile, hmacSha256Hex, listAppFiles, parseActor, putAppFile, putAppFileStream, randomHex, resolvePlatformWebhookBase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprigr/apps-app-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",