filecheck-node 0.2.0 → 0.3.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.cjs +184 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +173 -17
- package/dist/index.d.ts +173 -17
- package/dist/index.js +184 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -97,6 +97,17 @@ interface JobSummary {
|
|
|
97
97
|
}>;
|
|
98
98
|
created: number | null;
|
|
99
99
|
finalized: string;
|
|
100
|
+
/** Set when the job errored before any file could be processed (e.g. every source failed). */
|
|
101
|
+
error?: string;
|
|
102
|
+
/** Each source that could not be collated, and why. */
|
|
103
|
+
failedSources?: FailedSource[];
|
|
104
|
+
}
|
|
105
|
+
/** A source the API could not turn into a task (unreachable or refused URL, missing upload). */
|
|
106
|
+
interface FailedSource {
|
|
107
|
+
index: number;
|
|
108
|
+
source: string | null;
|
|
109
|
+
fileRef: string | null;
|
|
110
|
+
error: string;
|
|
100
111
|
}
|
|
101
112
|
interface ResultHeader {
|
|
102
113
|
taskId: string;
|
|
@@ -321,7 +332,7 @@ declare const webhooks: {
|
|
|
321
332
|
* resources.
|
|
322
333
|
*/
|
|
323
334
|
interface HttpRequest {
|
|
324
|
-
method: 'GET' | 'POST' | 'DELETE';
|
|
335
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
325
336
|
url: string;
|
|
326
337
|
headers: Record<string, string>;
|
|
327
338
|
/** JSON string, multipart form data, or nothing. */
|
|
@@ -356,6 +367,7 @@ type FetchLike = (url: string, init: {
|
|
|
356
367
|
text(): Promise<string>;
|
|
357
368
|
}>;
|
|
358
369
|
|
|
370
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
359
371
|
interface RequestOptions {
|
|
360
372
|
query?: Record<string, string | number | boolean | undefined>;
|
|
361
373
|
body?: unknown;
|
|
@@ -370,9 +382,9 @@ declare class Requestor {
|
|
|
370
382
|
private readonly timeoutMs;
|
|
371
383
|
private readonly maxRetries;
|
|
372
384
|
constructor(transport: HttpTransport, baseUrl: string, secretKey: string, timeoutMs: number, maxRetries: number);
|
|
373
|
-
raw(method:
|
|
385
|
+
raw(method: HttpMethod, path: string, options?: RequestOptions): Promise<HttpResponse>;
|
|
374
386
|
/** Request + parse. Throws a typed FilecheckError on any non-2xx. */
|
|
375
|
-
json<T>(method:
|
|
387
|
+
json<T>(method: HttpMethod, path: string, options?: RequestOptions): Promise<{
|
|
376
388
|
status: number;
|
|
377
389
|
data: T;
|
|
378
390
|
}>;
|
|
@@ -443,10 +455,18 @@ interface JobContext {
|
|
|
443
455
|
min_mm?: number;
|
|
444
456
|
};
|
|
445
457
|
}
|
|
446
|
-
/** `POST /jobs`.
|
|
458
|
+
/** `POST /jobs`. */
|
|
447
459
|
interface CreateJobParams {
|
|
448
460
|
sources: CreateJobSource[];
|
|
449
461
|
ruleId?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Run the files through a workflow's intake (`wf_…`), as the storefront does
|
|
464
|
+
* for a product mapped to it: its rule replaces `ruleId` and `sources[].steps`.
|
|
465
|
+
* Drafts work too, so a workflow can be tried before it is published.
|
|
466
|
+
*/
|
|
467
|
+
workflowId?: string;
|
|
468
|
+
/** An unsaved workflow record to run the files through (kept a day, then discarded). */
|
|
469
|
+
previewWorkflow?: Record<string, unknown>;
|
|
450
470
|
channel?: 'api' | 'store' | 'admin';
|
|
451
471
|
customerId?: string;
|
|
452
472
|
orderId?: string;
|
|
@@ -622,28 +642,84 @@ declare class JobsResource {
|
|
|
622
642
|
}
|
|
623
643
|
|
|
624
644
|
/**
|
|
625
|
-
*
|
|
626
|
-
* (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
645
|
+
* A record from one of the setup collections. Beyond `id`, `enabled`, and
|
|
646
|
+
* `source` (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
647
|
+
* free-form: the API's JSON schemas describe them.
|
|
627
648
|
*/
|
|
628
649
|
interface LibraryItem {
|
|
629
650
|
id: string;
|
|
630
651
|
enabled?: boolean;
|
|
631
652
|
source?: 'domain' | 'store';
|
|
653
|
+
draft?: boolean;
|
|
654
|
+
customized?: boolean;
|
|
632
655
|
[key: string]: unknown;
|
|
633
656
|
}
|
|
657
|
+
/** What a write answers: the record as saved (or as it would be, with `dryRun`). */
|
|
658
|
+
interface WriteResult<T = LibraryItem> {
|
|
659
|
+
record: T;
|
|
660
|
+
/** True when nothing was saved (`dryRun: true` was sent). */
|
|
661
|
+
dryRun?: boolean;
|
|
662
|
+
}
|
|
663
|
+
/** `publish()`: the record, live now, and every id published with it (drafts it pointed at come first). */
|
|
664
|
+
interface PublishResult extends WriteResult {
|
|
665
|
+
published: string[];
|
|
666
|
+
}
|
|
667
|
+
/** `revert()`: the catalog record that applies again, and whether there was a copy to drop. */
|
|
668
|
+
interface RevertResult extends WriteResult {
|
|
669
|
+
reverted: boolean;
|
|
670
|
+
}
|
|
671
|
+
/** `del()`: `{ id, deleted: true }`. */
|
|
672
|
+
interface DeletedRecord {
|
|
673
|
+
id?: string;
|
|
674
|
+
deleted: true;
|
|
675
|
+
[key: string]: unknown;
|
|
676
|
+
}
|
|
677
|
+
interface CreateOptions {
|
|
678
|
+
/** Save as a draft: hidden from the storefront and dashboard until published; jobs can still run against it by id. */
|
|
679
|
+
draft?: boolean;
|
|
680
|
+
/** Validate and check references without saving. */
|
|
681
|
+
dryRun?: boolean;
|
|
682
|
+
}
|
|
683
|
+
interface UpdateOptions {
|
|
684
|
+
/** Validate and check references without saving. */
|
|
685
|
+
dryRun?: boolean;
|
|
686
|
+
}
|
|
634
687
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
688
|
+
* List / get / create / update (JSON Merge Patch) / delete over one API
|
|
689
|
+
* collection. Envelope keys differ per resource (and are not always the path
|
|
690
|
+
* name — optimize-presets uses `presets`).
|
|
638
691
|
*/
|
|
639
|
-
declare class
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
692
|
+
declare class RecordResource<T = LibraryItem> {
|
|
693
|
+
protected readonly requestor: Requestor;
|
|
694
|
+
protected readonly path: string;
|
|
695
|
+
protected readonly listKey: string;
|
|
696
|
+
protected readonly itemKey: string;
|
|
644
697
|
constructor(requestor: Requestor, path: string, listKey: string, itemKey: string);
|
|
645
|
-
|
|
646
|
-
|
|
698
|
+
protected url(id: string, suffix?: string): string;
|
|
699
|
+
protected listWith(query?: Record<string, string | undefined>): Promise<T[]>;
|
|
700
|
+
protected toResult<R extends WriteResult<T>>(data: Record<string, unknown>): R;
|
|
701
|
+
list(): Promise<T[]>;
|
|
702
|
+
retrieve(id: string): Promise<T>;
|
|
703
|
+
create(record: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
704
|
+
/** A JSON Merge Patch (RFC 7396): send only what changes; `null` removes a key; arrays replace. */
|
|
705
|
+
update(id: string, patch: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
706
|
+
del(id: string): Promise<DeletedRecord>;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* The catalog collections — workflows, rules, profiles, connectors, optimize
|
|
710
|
+
* presets: your records merged with the built-in catalog, copy-on-write
|
|
711
|
+
* customisation, drafts.
|
|
712
|
+
*/
|
|
713
|
+
declare class LibraryResource extends RecordResource<LibraryItem> {
|
|
714
|
+
/** `drafts: true` includes your unpublished drafts (marked `draft: true`). */
|
|
715
|
+
list(options?: {
|
|
716
|
+
drafts?: boolean;
|
|
717
|
+
}): Promise<LibraryItem[]>;
|
|
718
|
+
create(record: Record<string, unknown>, options?: CreateOptions): Promise<WriteResult>;
|
|
719
|
+
/** Makes a draft live, with the drafts it points at. */
|
|
720
|
+
publish(id: string): Promise<PublishResult>;
|
|
721
|
+
/** Drops your copy of a catalog record (or un-hides one you deleted). */
|
|
722
|
+
revert(id: string): Promise<RevertResult>;
|
|
647
723
|
}
|
|
648
724
|
|
|
649
725
|
declare class OrdersResource {
|
|
@@ -653,6 +729,80 @@ declare class OrdersResource {
|
|
|
653
729
|
create(orderId: string, params: Record<string, unknown>): Promise<OrderResult>;
|
|
654
730
|
}
|
|
655
731
|
|
|
732
|
+
/** A record whose shape the API's JSON schema describes (destination, webhook, settings…). */
|
|
733
|
+
type SetupRecord = Record<string, unknown> & {
|
|
734
|
+
id?: string;
|
|
735
|
+
};
|
|
736
|
+
/** `POST …/{id}/test`: whether the sample delivery got through. */
|
|
737
|
+
interface TestResult {
|
|
738
|
+
ok: boolean;
|
|
739
|
+
[key: string]: unknown;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Delivery destinations: SFTP / FTP hotfolders, S3, webhooks, email. Secret
|
|
743
|
+
* params are write-only and read back as `********`.
|
|
744
|
+
*/
|
|
745
|
+
declare class DestinationsResource extends RecordResource<SetupRecord> {
|
|
746
|
+
constructor(requestor: Requestor);
|
|
747
|
+
/**
|
|
748
|
+
* Delivers a sample order (TEST-1001, one-page Sample_Product.pdf) through
|
|
749
|
+
* the real transport. Hotfolders really receive the file.
|
|
750
|
+
*/
|
|
751
|
+
test(id: string): Promise<TestResult>;
|
|
752
|
+
}
|
|
753
|
+
/** HTTP callbacks for job, proof, account and billing events. */
|
|
754
|
+
declare class WebhooksResource extends RecordResource<SetupRecord> {
|
|
755
|
+
constructor(requestor: Requestor);
|
|
756
|
+
/** The event types a webhook can subscribe to. */
|
|
757
|
+
events(): Promise<SetupRecord[]>;
|
|
758
|
+
/** Sends a signed test event to the webhook's URL. */
|
|
759
|
+
test(id: string): Promise<TestResult>;
|
|
760
|
+
}
|
|
761
|
+
interface ProductMap {
|
|
762
|
+
productId: string;
|
|
763
|
+
workflowId?: string | null;
|
|
764
|
+
title?: string;
|
|
765
|
+
url?: string | null;
|
|
766
|
+
[key: string]: unknown;
|
|
767
|
+
}
|
|
768
|
+
/** Which workflow each product in the store opens. */
|
|
769
|
+
declare class ProductMapsResource {
|
|
770
|
+
private readonly requestor;
|
|
771
|
+
constructor(requestor: Requestor);
|
|
772
|
+
list(): Promise<ProductMap[]>;
|
|
773
|
+
/** Maps a product (Shopify: its numeric id) to a published workflow. */
|
|
774
|
+
set(productId: string, map: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
775
|
+
record: ProductMap;
|
|
776
|
+
dryRun?: boolean;
|
|
777
|
+
}>;
|
|
778
|
+
del(productId: string): Promise<DeletedRecord>;
|
|
779
|
+
}
|
|
780
|
+
interface StoreProductPage {
|
|
781
|
+
products: SetupRecord[];
|
|
782
|
+
hasMore: boolean;
|
|
783
|
+
nextCursor: string | null;
|
|
784
|
+
}
|
|
785
|
+
/** Products in the connected store (Shopify), each with the workflow it is mapped to. */
|
|
786
|
+
declare class ProductsResource {
|
|
787
|
+
private readonly requestor;
|
|
788
|
+
constructor(requestor: Requestor);
|
|
789
|
+
search(params?: {
|
|
790
|
+
search?: string;
|
|
791
|
+
cursor?: string;
|
|
792
|
+
}): Promise<StoreProductPage>;
|
|
793
|
+
}
|
|
794
|
+
/** How the storefront Element appears on product pages. */
|
|
795
|
+
declare class SettingsResource {
|
|
796
|
+
private readonly requestor;
|
|
797
|
+
constructor(requestor: Requestor);
|
|
798
|
+
retrieve(): Promise<SetupRecord>;
|
|
799
|
+
/** Send only what changes; `null` puts a setting back to its default. */
|
|
800
|
+
update(patch: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
801
|
+
record: SetupRecord;
|
|
802
|
+
dryRun?: boolean;
|
|
803
|
+
}>;
|
|
804
|
+
}
|
|
805
|
+
|
|
656
806
|
type UploadInput = Blob | ArrayBuffer | ArrayBufferView | Buffer;
|
|
657
807
|
interface UploadOptions {
|
|
658
808
|
mimeType?: string;
|
|
@@ -699,6 +849,12 @@ declare class Filecheck {
|
|
|
699
849
|
readonly rules: LibraryResource;
|
|
700
850
|
readonly profiles: LibraryResource;
|
|
701
851
|
readonly optimizePresets: LibraryResource;
|
|
852
|
+
readonly destinations: DestinationsResource;
|
|
853
|
+
readonly productMaps: ProductMapsResource;
|
|
854
|
+
readonly products: ProductsResource;
|
|
855
|
+
readonly settings: SettingsResource;
|
|
856
|
+
/** Webhook endpoints (`/webhooks`). `webhooks` is the signature-verification helper. */
|
|
857
|
+
readonly webhookEndpoints: WebhooksResource;
|
|
702
858
|
readonly webhooks: {
|
|
703
859
|
constructEvent: typeof constructEvent;
|
|
704
860
|
computeSignature: typeof computeSignature;
|
|
@@ -749,4 +905,4 @@ declare class ConnectionError extends FilecheckError {
|
|
|
749
905
|
declare class WebhookSignatureError extends FilecheckError {
|
|
750
906
|
}
|
|
751
907
|
|
|
752
|
-
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type DeleteJobResult, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, RateLimitError, type Run, type SourceRef, type Step, type StepType, TERMINAL_STATUSES, type Task, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
|
908
|
+
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type CreateOptions, type DeleteJobResult, type DeletedRecord, DestinationsResource, type FailedSource, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, LibraryResource, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, type ProductMap, ProductMapsResource, ProductsResource, type PublishResult, RateLimitError, RecordResource, type RevertResult, type Run, SettingsResource, type SetupRecord, type SourceRef, type Step, type StepType, type StoreProductPage, TERMINAL_STATUSES, type Task, type TestResult, type UpdateOptions, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, WebhooksResource, type WriteResult, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,17 @@ interface JobSummary {
|
|
|
97
97
|
}>;
|
|
98
98
|
created: number | null;
|
|
99
99
|
finalized: string;
|
|
100
|
+
/** Set when the job errored before any file could be processed (e.g. every source failed). */
|
|
101
|
+
error?: string;
|
|
102
|
+
/** Each source that could not be collated, and why. */
|
|
103
|
+
failedSources?: FailedSource[];
|
|
104
|
+
}
|
|
105
|
+
/** A source the API could not turn into a task (unreachable or refused URL, missing upload). */
|
|
106
|
+
interface FailedSource {
|
|
107
|
+
index: number;
|
|
108
|
+
source: string | null;
|
|
109
|
+
fileRef: string | null;
|
|
110
|
+
error: string;
|
|
100
111
|
}
|
|
101
112
|
interface ResultHeader {
|
|
102
113
|
taskId: string;
|
|
@@ -321,7 +332,7 @@ declare const webhooks: {
|
|
|
321
332
|
* resources.
|
|
322
333
|
*/
|
|
323
334
|
interface HttpRequest {
|
|
324
|
-
method: 'GET' | 'POST' | 'DELETE';
|
|
335
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
325
336
|
url: string;
|
|
326
337
|
headers: Record<string, string>;
|
|
327
338
|
/** JSON string, multipart form data, or nothing. */
|
|
@@ -356,6 +367,7 @@ type FetchLike = (url: string, init: {
|
|
|
356
367
|
text(): Promise<string>;
|
|
357
368
|
}>;
|
|
358
369
|
|
|
370
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
359
371
|
interface RequestOptions {
|
|
360
372
|
query?: Record<string, string | number | boolean | undefined>;
|
|
361
373
|
body?: unknown;
|
|
@@ -370,9 +382,9 @@ declare class Requestor {
|
|
|
370
382
|
private readonly timeoutMs;
|
|
371
383
|
private readonly maxRetries;
|
|
372
384
|
constructor(transport: HttpTransport, baseUrl: string, secretKey: string, timeoutMs: number, maxRetries: number);
|
|
373
|
-
raw(method:
|
|
385
|
+
raw(method: HttpMethod, path: string, options?: RequestOptions): Promise<HttpResponse>;
|
|
374
386
|
/** Request + parse. Throws a typed FilecheckError on any non-2xx. */
|
|
375
|
-
json<T>(method:
|
|
387
|
+
json<T>(method: HttpMethod, path: string, options?: RequestOptions): Promise<{
|
|
376
388
|
status: number;
|
|
377
389
|
data: T;
|
|
378
390
|
}>;
|
|
@@ -443,10 +455,18 @@ interface JobContext {
|
|
|
443
455
|
min_mm?: number;
|
|
444
456
|
};
|
|
445
457
|
}
|
|
446
|
-
/** `POST /jobs`.
|
|
458
|
+
/** `POST /jobs`. */
|
|
447
459
|
interface CreateJobParams {
|
|
448
460
|
sources: CreateJobSource[];
|
|
449
461
|
ruleId?: string;
|
|
462
|
+
/**
|
|
463
|
+
* Run the files through a workflow's intake (`wf_…`), as the storefront does
|
|
464
|
+
* for a product mapped to it: its rule replaces `ruleId` and `sources[].steps`.
|
|
465
|
+
* Drafts work too, so a workflow can be tried before it is published.
|
|
466
|
+
*/
|
|
467
|
+
workflowId?: string;
|
|
468
|
+
/** An unsaved workflow record to run the files through (kept a day, then discarded). */
|
|
469
|
+
previewWorkflow?: Record<string, unknown>;
|
|
450
470
|
channel?: 'api' | 'store' | 'admin';
|
|
451
471
|
customerId?: string;
|
|
452
472
|
orderId?: string;
|
|
@@ -622,28 +642,84 @@ declare class JobsResource {
|
|
|
622
642
|
}
|
|
623
643
|
|
|
624
644
|
/**
|
|
625
|
-
*
|
|
626
|
-
* (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
645
|
+
* A record from one of the setup collections. Beyond `id`, `enabled`, and
|
|
646
|
+
* `source` (`'domain'` rows shadow same-id `'store'` rows), payloads are
|
|
647
|
+
* free-form: the API's JSON schemas describe them.
|
|
627
648
|
*/
|
|
628
649
|
interface LibraryItem {
|
|
629
650
|
id: string;
|
|
630
651
|
enabled?: boolean;
|
|
631
652
|
source?: 'domain' | 'store';
|
|
653
|
+
draft?: boolean;
|
|
654
|
+
customized?: boolean;
|
|
632
655
|
[key: string]: unknown;
|
|
633
656
|
}
|
|
657
|
+
/** What a write answers: the record as saved (or as it would be, with `dryRun`). */
|
|
658
|
+
interface WriteResult<T = LibraryItem> {
|
|
659
|
+
record: T;
|
|
660
|
+
/** True when nothing was saved (`dryRun: true` was sent). */
|
|
661
|
+
dryRun?: boolean;
|
|
662
|
+
}
|
|
663
|
+
/** `publish()`: the record, live now, and every id published with it (drafts it pointed at come first). */
|
|
664
|
+
interface PublishResult extends WriteResult {
|
|
665
|
+
published: string[];
|
|
666
|
+
}
|
|
667
|
+
/** `revert()`: the catalog record that applies again, and whether there was a copy to drop. */
|
|
668
|
+
interface RevertResult extends WriteResult {
|
|
669
|
+
reverted: boolean;
|
|
670
|
+
}
|
|
671
|
+
/** `del()`: `{ id, deleted: true }`. */
|
|
672
|
+
interface DeletedRecord {
|
|
673
|
+
id?: string;
|
|
674
|
+
deleted: true;
|
|
675
|
+
[key: string]: unknown;
|
|
676
|
+
}
|
|
677
|
+
interface CreateOptions {
|
|
678
|
+
/** Save as a draft: hidden from the storefront and dashboard until published; jobs can still run against it by id. */
|
|
679
|
+
draft?: boolean;
|
|
680
|
+
/** Validate and check references without saving. */
|
|
681
|
+
dryRun?: boolean;
|
|
682
|
+
}
|
|
683
|
+
interface UpdateOptions {
|
|
684
|
+
/** Validate and check references without saving. */
|
|
685
|
+
dryRun?: boolean;
|
|
686
|
+
}
|
|
634
687
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
688
|
+
* List / get / create / update (JSON Merge Patch) / delete over one API
|
|
689
|
+
* collection. Envelope keys differ per resource (and are not always the path
|
|
690
|
+
* name — optimize-presets uses `presets`).
|
|
638
691
|
*/
|
|
639
|
-
declare class
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
692
|
+
declare class RecordResource<T = LibraryItem> {
|
|
693
|
+
protected readonly requestor: Requestor;
|
|
694
|
+
protected readonly path: string;
|
|
695
|
+
protected readonly listKey: string;
|
|
696
|
+
protected readonly itemKey: string;
|
|
644
697
|
constructor(requestor: Requestor, path: string, listKey: string, itemKey: string);
|
|
645
|
-
|
|
646
|
-
|
|
698
|
+
protected url(id: string, suffix?: string): string;
|
|
699
|
+
protected listWith(query?: Record<string, string | undefined>): Promise<T[]>;
|
|
700
|
+
protected toResult<R extends WriteResult<T>>(data: Record<string, unknown>): R;
|
|
701
|
+
list(): Promise<T[]>;
|
|
702
|
+
retrieve(id: string): Promise<T>;
|
|
703
|
+
create(record: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
704
|
+
/** A JSON Merge Patch (RFC 7396): send only what changes; `null` removes a key; arrays replace. */
|
|
705
|
+
update(id: string, patch: Record<string, unknown>, options?: UpdateOptions): Promise<WriteResult<T>>;
|
|
706
|
+
del(id: string): Promise<DeletedRecord>;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* The catalog collections — workflows, rules, profiles, connectors, optimize
|
|
710
|
+
* presets: your records merged with the built-in catalog, copy-on-write
|
|
711
|
+
* customisation, drafts.
|
|
712
|
+
*/
|
|
713
|
+
declare class LibraryResource extends RecordResource<LibraryItem> {
|
|
714
|
+
/** `drafts: true` includes your unpublished drafts (marked `draft: true`). */
|
|
715
|
+
list(options?: {
|
|
716
|
+
drafts?: boolean;
|
|
717
|
+
}): Promise<LibraryItem[]>;
|
|
718
|
+
create(record: Record<string, unknown>, options?: CreateOptions): Promise<WriteResult>;
|
|
719
|
+
/** Makes a draft live, with the drafts it points at. */
|
|
720
|
+
publish(id: string): Promise<PublishResult>;
|
|
721
|
+
/** Drops your copy of a catalog record (or un-hides one you deleted). */
|
|
722
|
+
revert(id: string): Promise<RevertResult>;
|
|
647
723
|
}
|
|
648
724
|
|
|
649
725
|
declare class OrdersResource {
|
|
@@ -653,6 +729,80 @@ declare class OrdersResource {
|
|
|
653
729
|
create(orderId: string, params: Record<string, unknown>): Promise<OrderResult>;
|
|
654
730
|
}
|
|
655
731
|
|
|
732
|
+
/** A record whose shape the API's JSON schema describes (destination, webhook, settings…). */
|
|
733
|
+
type SetupRecord = Record<string, unknown> & {
|
|
734
|
+
id?: string;
|
|
735
|
+
};
|
|
736
|
+
/** `POST …/{id}/test`: whether the sample delivery got through. */
|
|
737
|
+
interface TestResult {
|
|
738
|
+
ok: boolean;
|
|
739
|
+
[key: string]: unknown;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Delivery destinations: SFTP / FTP hotfolders, S3, webhooks, email. Secret
|
|
743
|
+
* params are write-only and read back as `********`.
|
|
744
|
+
*/
|
|
745
|
+
declare class DestinationsResource extends RecordResource<SetupRecord> {
|
|
746
|
+
constructor(requestor: Requestor);
|
|
747
|
+
/**
|
|
748
|
+
* Delivers a sample order (TEST-1001, one-page Sample_Product.pdf) through
|
|
749
|
+
* the real transport. Hotfolders really receive the file.
|
|
750
|
+
*/
|
|
751
|
+
test(id: string): Promise<TestResult>;
|
|
752
|
+
}
|
|
753
|
+
/** HTTP callbacks for job, proof, account and billing events. */
|
|
754
|
+
declare class WebhooksResource extends RecordResource<SetupRecord> {
|
|
755
|
+
constructor(requestor: Requestor);
|
|
756
|
+
/** The event types a webhook can subscribe to. */
|
|
757
|
+
events(): Promise<SetupRecord[]>;
|
|
758
|
+
/** Sends a signed test event to the webhook's URL. */
|
|
759
|
+
test(id: string): Promise<TestResult>;
|
|
760
|
+
}
|
|
761
|
+
interface ProductMap {
|
|
762
|
+
productId: string;
|
|
763
|
+
workflowId?: string | null;
|
|
764
|
+
title?: string;
|
|
765
|
+
url?: string | null;
|
|
766
|
+
[key: string]: unknown;
|
|
767
|
+
}
|
|
768
|
+
/** Which workflow each product in the store opens. */
|
|
769
|
+
declare class ProductMapsResource {
|
|
770
|
+
private readonly requestor;
|
|
771
|
+
constructor(requestor: Requestor);
|
|
772
|
+
list(): Promise<ProductMap[]>;
|
|
773
|
+
/** Maps a product (Shopify: its numeric id) to a published workflow. */
|
|
774
|
+
set(productId: string, map: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
775
|
+
record: ProductMap;
|
|
776
|
+
dryRun?: boolean;
|
|
777
|
+
}>;
|
|
778
|
+
del(productId: string): Promise<DeletedRecord>;
|
|
779
|
+
}
|
|
780
|
+
interface StoreProductPage {
|
|
781
|
+
products: SetupRecord[];
|
|
782
|
+
hasMore: boolean;
|
|
783
|
+
nextCursor: string | null;
|
|
784
|
+
}
|
|
785
|
+
/** Products in the connected store (Shopify), each with the workflow it is mapped to. */
|
|
786
|
+
declare class ProductsResource {
|
|
787
|
+
private readonly requestor;
|
|
788
|
+
constructor(requestor: Requestor);
|
|
789
|
+
search(params?: {
|
|
790
|
+
search?: string;
|
|
791
|
+
cursor?: string;
|
|
792
|
+
}): Promise<StoreProductPage>;
|
|
793
|
+
}
|
|
794
|
+
/** How the storefront Element appears on product pages. */
|
|
795
|
+
declare class SettingsResource {
|
|
796
|
+
private readonly requestor;
|
|
797
|
+
constructor(requestor: Requestor);
|
|
798
|
+
retrieve(): Promise<SetupRecord>;
|
|
799
|
+
/** Send only what changes; `null` puts a setting back to its default. */
|
|
800
|
+
update(patch: Record<string, unknown>, options?: UpdateOptions): Promise<{
|
|
801
|
+
record: SetupRecord;
|
|
802
|
+
dryRun?: boolean;
|
|
803
|
+
}>;
|
|
804
|
+
}
|
|
805
|
+
|
|
656
806
|
type UploadInput = Blob | ArrayBuffer | ArrayBufferView | Buffer;
|
|
657
807
|
interface UploadOptions {
|
|
658
808
|
mimeType?: string;
|
|
@@ -699,6 +849,12 @@ declare class Filecheck {
|
|
|
699
849
|
readonly rules: LibraryResource;
|
|
700
850
|
readonly profiles: LibraryResource;
|
|
701
851
|
readonly optimizePresets: LibraryResource;
|
|
852
|
+
readonly destinations: DestinationsResource;
|
|
853
|
+
readonly productMaps: ProductMapsResource;
|
|
854
|
+
readonly products: ProductsResource;
|
|
855
|
+
readonly settings: SettingsResource;
|
|
856
|
+
/** Webhook endpoints (`/webhooks`). `webhooks` is the signature-verification helper. */
|
|
857
|
+
readonly webhookEndpoints: WebhooksResource;
|
|
702
858
|
readonly webhooks: {
|
|
703
859
|
constructEvent: typeof constructEvent;
|
|
704
860
|
computeSignature: typeof computeSignature;
|
|
@@ -749,4 +905,4 @@ declare class ConnectionError extends FilecheckError {
|
|
|
749
905
|
declare class WebhookSignatureError extends FilecheckError {
|
|
750
906
|
}
|
|
751
907
|
|
|
752
|
-
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type DeleteJobResult, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, RateLimitError, type Run, type SourceRef, type Step, type StepType, TERMINAL_STATUSES, type Task, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|
|
908
|
+
export { APIError, type Artifact, AuthenticationError, ConnectionError, type ConstructEventOptions, type CreateJobParams, type CreateJobSource, type CreateOptions, type DeleteJobResult, type DeletedRecord, DestinationsResource, type FailedSource, type FetchLike, type FileType, Filecheck, type FilecheckClientOptions, FilecheckError, type FixParams, type FixSource, type HttpRequest, type HttpResponse, type HttpTransport, InvalidRequestError, type Job, type JobCompletedPayload, type JobContext, type JobCreatedPayload, type JobPage, type JobResult, type JobRuns, type JobStatus, type JobStepInput, type JobSummary, type LibraryItem, LibraryResource, type ListJobsParams, NotFoundError, type OnFailPolicy, type OptimizeParams, type OptimizeResult, type OptimizeSource, type OrderResult, type Outcome, type PreflightParams, type PreflightResult, type PreflightSource, type PreviewsParams, type PreviewsSource, type ProductMap, ProductMapsResource, ProductsResource, type PublishResult, RateLimitError, RecordResource, type RevertResult, type Run, SettingsResource, type SetupRecord, type SourceRef, type Step, type StepType, type StoreProductPage, TERMINAL_STATUSES, type Task, type TestResult, type UpdateOptions, type UploadInput, type UploadOptions, type UploadResult, type ValidateParams, type ValidateProfileCode, type ValidateProfileResult, type ValidateResult, type ValidateSource, type VerifyOptions, type VerifyReason, type VerifyResult, type VerifyState, type WaitOptions, type WebhookEvent, type WebhookParam, WebhookSignatureError, WebhooksResource, type WriteResult, computeSignature, constructEvent, Filecheck as default, isTerminal, maskKey, resolveVerify, webhooks };
|