@sprigr/apps-app-sdk 0.1.0 → 0.1.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.
- package/dist/index.d.ts +75 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -589,6 +589,80 @@ 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. */
|
|
605
|
+
format: 'docx' | 'xlsx' | 'pdf';
|
|
606
|
+
operations: Array<Record<string, unknown>>;
|
|
607
|
+
output_filename?: string;
|
|
608
|
+
output_key?: string;
|
|
609
|
+
allow_lossy?: boolean;
|
|
610
|
+
/** Deterministic idempotency token: the platform persists the pipeline's
|
|
611
|
+
* terminal result under it, so a retry of the same logical edit after a
|
|
612
|
+
* dispatch timeout replays the finished result instead of re-running the
|
|
613
|
+
* engine. Filename-safe: ^[A-Za-z0-9_-]{8,128}$. */
|
|
614
|
+
job_token?: string;
|
|
615
|
+
}
|
|
616
|
+
/** Result from `env.SPRIGR.files.edit`. */
|
|
617
|
+
interface SprigrFilesEditResult {
|
|
618
|
+
ok: boolean;
|
|
619
|
+
out_file_key?: string;
|
|
620
|
+
size?: number;
|
|
621
|
+
operations_applied?: Array<Record<string, unknown>>;
|
|
622
|
+
failed_operations?: Array<Record<string, unknown>>;
|
|
623
|
+
warning?: string;
|
|
624
|
+
error?: string;
|
|
625
|
+
}
|
|
626
|
+
/** Input to `env.SPRIGR.files.create` (build a NEW docx/xlsx from a spec). */
|
|
627
|
+
interface SprigrFilesCreateInput {
|
|
628
|
+
format: 'docx' | 'xlsx';
|
|
629
|
+
/** docx: content blocks (heading/paragraph/table/…). xlsx: sheet defs ({name, headers, rows, …}). */
|
|
630
|
+
spec: Array<Record<string, unknown>>;
|
|
631
|
+
properties?: Record<string, unknown>;
|
|
632
|
+
output_filename?: string;
|
|
633
|
+
output_key?: string;
|
|
634
|
+
/** Same idempotency semantics as SprigrFilesEditInput.job_token. */
|
|
635
|
+
job_token?: string;
|
|
636
|
+
}
|
|
637
|
+
/** Result from `env.SPRIGR.files.create`. */
|
|
638
|
+
interface SprigrFilesCreateResult {
|
|
639
|
+
ok: boolean;
|
|
640
|
+
out_file_key?: string;
|
|
641
|
+
size?: number;
|
|
642
|
+
error?: string;
|
|
643
|
+
}
|
|
644
|
+
/** Result from `env.SPRIGR.files.job` (read-only job-record status). */
|
|
645
|
+
interface SprigrFilesJobResult {
|
|
646
|
+
ok: boolean;
|
|
647
|
+
job_token: string;
|
|
648
|
+
status: 'not_found' | 'running' | 'done' | 'error';
|
|
649
|
+
/** True when the record is older than the platform's freshness windows
|
|
650
|
+
* (an orphaned `running` or an expired terminal record). */
|
|
651
|
+
stale?: boolean;
|
|
652
|
+
started_at?: number;
|
|
653
|
+
finished_at?: number;
|
|
654
|
+
http_status?: number;
|
|
655
|
+
/** The stored edit/create response body (terminal records only). */
|
|
656
|
+
result?: Record<string, unknown>;
|
|
657
|
+
}
|
|
658
|
+
/** The platform files bridge plus the document-engine methods. */
|
|
659
|
+
interface SprigrFilesApiWithEdit extends SprigrFilesApi {
|
|
660
|
+
edit(input: SprigrFilesEditInput): Promise<SprigrFilesEditResult>;
|
|
661
|
+
create(input: SprigrFilesCreateInput): Promise<SprigrFilesCreateResult>;
|
|
662
|
+
/** Optional: absent on wrapper builds older than the job-token surface;
|
|
663
|
+
* callers must feature-detect. */
|
|
664
|
+
job?(jobToken: string): Promise<SprigrFilesJobResult>;
|
|
665
|
+
}
|
|
592
666
|
/** Narrow structural type for the per-install D1 binding. */
|
|
593
667
|
interface D1Like {
|
|
594
668
|
prepare(sql: string): D1PreparedStatementLike;
|
|
@@ -626,4 +700,4 @@ interface ExecutionContextLike {
|
|
|
626
700
|
}
|
|
627
701
|
type HandlerFn<TArgs, TResult> = (args: TArgs, env: Record<string, unknown>, ctx?: ExecutionContextLike) => Promise<TResult>;
|
|
628
702
|
|
|
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 };
|
|
703
|
+
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 };
|