@shushed/helpers 0.0.20 → 0.0.22

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
  import { DeepRedact } from '@hackylabs/deep-redact';
3
+ import { DocumentReference, Firestore } from '@google-cloud/firestore';
4
+ import { PubSub, Topic, Subscription } from '@google-cloud/pubsub';
5
+ import * as _google_cloud_scheduler_build_protos_protos from '@google-cloud/scheduler/build/protos/protos';
6
+ import { CloudSchedulerClient } from '@google-cloud/scheduler';
7
+ import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
3
8
 
4
9
  declare const schema$l: {
5
10
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -118,6 +123,7 @@ declare const schema$i: {
118
123
  readonly attributes: {
119
124
  readonly type: "object";
120
125
  readonly additionalProperties: false;
126
+ readonly required: readonly ["product_type", "product_category", "product_subcategory", "division", "care_instructions", "range", "main_fibre", "size_range", "sizes", "occasion", "strategy_type", "pattern_name", "neckline", "sleeve_length", "leg_length", "heel_height", "heel_shape", "toe_shape", "handle_straps", "fastening", "sole_code", "fashionability", "weight", "average_weight_grams", "length_measurement", "fabric_composition_footwear"];
121
127
  readonly properties: {
122
128
  readonly product_type: {
123
129
  readonly type: "string";
@@ -216,6 +222,7 @@ declare const schema$i: {
216
222
  readonly cost: {
217
223
  readonly type: "object";
218
224
  readonly additionalProperties: false;
225
+ readonly required: readonly ["retail_price", "current_cost", "moq", "finishing_cost", "other_costs", "freight_rate", "duty_rate", "commodity_code_ref"];
219
226
  readonly properties: {
220
227
  readonly retail_price: {
221
228
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -515,6 +522,7 @@ declare const schema$i: {
515
522
  readonly supplier_data: {
516
523
  readonly type: "object";
517
524
  readonly additionalProperties: false;
525
+ readonly required: readonly ["country_of_origin", "port_of_origin", "supplier_id", "factory_id"];
518
526
  readonly properties: {
519
527
  readonly country_of_origin: {
520
528
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -554,7 +562,7 @@ declare const schema$i: {
554
562
  };
555
563
  };
556
564
  };
557
- readonly required: readonly ["product_name", "colour_label", "developement_colourway_id", "colour_id", "style_id", "season_id", "drop_name", "stock_type", "block", "packing_method", "is_bought_in_product", "is_carry_over", "image_url", "product_type", "product_category", "division", "care_instructions", "range", "main_fibre", "size_range", "sizes", "occasion", "strategy_type", "pattern_name", "neckline", "sleeve_length", "leg_length", "heel_height", "heel_shape", "toe_shape", "handle_straps", "fastening", "sole_code", "fashionability", "weight", "average_weight_grams", "length_measurement", "fabric_composition_footwear", "retail_price", "current_cost", "currency", "moq", "finishing_cost", "other_costs", "freight_rate", "duty_rate", "commodity_code_ref", "country_of_origin", "port_of_origin", "supplier_id", "factory_id"];
565
+ readonly required: readonly ["product_name", "colour_label", "developement_colourway_id", "colour_id", "style_id", "season_name", "drop_name", "stock_type", "block", "packing_method", "is_bought_in_product", "is_carry_over", "image_url", "attributes", "cost", "supplier_data"];
558
566
  readonly $id: "https://shushed.example.com/product-draft.schema.json";
559
567
  };
560
568
 
@@ -812,6 +820,7 @@ declare const schema$f: {
812
820
  readonly attributes: {
813
821
  readonly type: "object";
814
822
  readonly additionalProperties: false;
823
+ readonly required: readonly ["product_type", "product_category", "product_subcategory", "division", "care_instructions", "range", "main_fibre", "size_range", "sizes", "occasion", "strategy_type", "pattern_name", "neckline", "sleeve_length", "leg_length", "heel_height", "heel_shape", "toe_shape", "handle_straps", "fastening", "sole_code", "fashionability", "weight", "average_weight_grams", "length_measurement", "fabric_composition_footwear"];
815
824
  readonly properties: {
816
825
  readonly product_type: {
817
826
  readonly type: "string";
@@ -910,6 +919,7 @@ declare const schema$f: {
910
919
  readonly cost: {
911
920
  readonly type: "object";
912
921
  readonly additionalProperties: false;
922
+ readonly required: readonly ["retail_price", "current_cost", "moq", "finishing_cost", "other_costs", "freight_rate", "duty_rate", "commodity_code_ref"];
913
923
  readonly properties: {
914
924
  readonly retail_price: {
915
925
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -1209,6 +1219,7 @@ declare const schema$f: {
1209
1219
  readonly supplier_data: {
1210
1220
  readonly type: "object";
1211
1221
  readonly additionalProperties: false;
1222
+ readonly required: readonly ["country_of_origin", "port_of_origin", "supplier_id", "factory_id"];
1212
1223
  readonly properties: {
1213
1224
  readonly country_of_origin: {
1214
1225
  readonly $schema: "http://json-schema.org/draft-07/schema#";
@@ -1248,7 +1259,7 @@ declare const schema$f: {
1248
1259
  };
1249
1260
  };
1250
1261
  };
1251
- readonly required: readonly ["product_name", "colour_label", "developement_colourway_id", "colour_id", "style_id", "season_id", "drop_name", "stock_type", "block", "packing_method", "is_bought_in_product", "is_carry_over", "image_url", "product_type", "product_category", "division", "care_instructions", "range", "main_fibre", "size_range", "sizes", "occasion", "strategy_type", "pattern_name", "neckline", "sleeve_length", "leg_length", "heel_height", "heel_shape", "toe_shape", "handle_straps", "fastening", "sole_code", "fashionability", "weight", "average_weight_grams", "length_measurement", "fabric_composition_footwear", "retail_price", "current_cost", "currency", "moq", "finishing_cost", "other_costs", "freight_rate", "duty_rate", "commodity_code_ref", "country_of_origin", "port_of_origin", "supplier_id", "factory_id"];
1262
+ readonly required: readonly ["product_name", "colour_label", "developement_colourway_id", "colour_id", "style_id", "season_name", "drop_name", "stock_type", "block", "packing_method", "is_bought_in_product", "is_carry_over", "image_url", "attributes", "cost", "supplier_data"];
1252
1263
  }, {
1253
1264
  readonly type: "object";
1254
1265
  readonly additionalProperties: false;
@@ -26582,7 +26593,7 @@ interface __MainSchema$n {
26582
26593
  developement_colourway_id: string;
26583
26594
  colour_id: string;
26584
26595
  style_id: string;
26585
- season_name?: string;
26596
+ season_name: string;
26586
26597
  drop_name: ("January" | "February" | "March" | "April" | "May" | "June" | "July" | "August" | "September" | "October" | "November" | "December" | "Carryover");
26587
26598
  development_style_id?: string;
26588
26599
  stock_type: string;
@@ -26592,58 +26603,58 @@ interface __MainSchema$n {
26592
26603
  reprocess_method?: (string | null);
26593
26604
  is_carry_over: boolean;
26594
26605
  image_url: string;
26595
- attributes?: {
26596
- product_type?: string;
26597
- product_category?: string;
26598
- product_subcategory?: string;
26599
- division?: ("Women" | null);
26600
- care_instructions?: string;
26601
- range?: (("Main Collection" | "Seasonal") | null);
26602
- main_fibre?: string;
26603
- size_range?: string;
26604
- sizes?: string;
26605
- occasion?: string;
26606
- strategy_type?: string;
26607
- pattern_name?: string;
26608
- neckline?: string;
26609
- sleeve_length?: (string | null);
26610
- leg_length?: (string | null);
26611
- heel_height?: (string | null);
26612
- heel_shape?: string;
26613
- toe_shape?: string;
26614
- handle_straps?: string;
26615
- fastening?: string;
26616
- sole_code?: string;
26617
- fashionability?: ("Core" | null);
26606
+ attributes: {
26607
+ product_type: string;
26608
+ product_category: string;
26609
+ product_subcategory: string;
26610
+ division: ("Women" | null);
26611
+ care_instructions: string;
26612
+ range: (("Main Collection" | "Seasonal") | null);
26613
+ main_fibre: string;
26614
+ size_range: string;
26615
+ sizes: string;
26616
+ occasion: string;
26617
+ strategy_type: string;
26618
+ pattern_name: string;
26619
+ neckline: string;
26620
+ sleeve_length: (string | null);
26621
+ leg_length: (string | null);
26622
+ heel_height: (string | null);
26623
+ heel_shape: string;
26624
+ toe_shape: string;
26625
+ handle_straps: string;
26626
+ fastening: string;
26627
+ sole_code: string;
26628
+ fashionability: ("Core" | null);
26618
26629
  fashion_type?: string;
26619
26630
  development_type?: string;
26620
- weight?: (string | null);
26621
- average_weight_grams?: number;
26631
+ weight: (string | null);
26632
+ average_weight_grams: number;
26622
26633
  extra_selling_point?: string;
26623
- length_measurement?: (string | null);
26624
- fabric_composition_footwear?: string;
26634
+ length_measurement: (string | null);
26635
+ fabric_composition_footwear: string;
26625
26636
  };
26626
- cost?: {
26627
- retail_price?: Money$a;
26628
- current_cost?: Money$a;
26629
- moq?: number;
26630
- finishing_cost?: Money$a;
26631
- other_costs?: Money$a;
26637
+ cost: {
26638
+ retail_price: Money$a;
26639
+ current_cost: Money$a;
26640
+ moq: number;
26641
+ finishing_cost: Money$a;
26642
+ other_costs: Money$a;
26632
26643
  commission?: Money$a;
26633
- freight_rate?: Money$a;
26634
- duty_rate?: Money$a;
26635
- commodity_code_ref?: string;
26644
+ freight_rate: Money$a;
26645
+ duty_rate: Money$a;
26646
+ commodity_code_ref: string;
26636
26647
  };
26637
26648
  payment_terms?: {
26638
26649
  supplier_payment_terms?: (string | null);
26639
26650
  supplier_inco_terms?: string;
26640
26651
  };
26641
- supplier_data?: {
26642
- country_of_origin?: Country$9;
26643
- port_of_origin?: string;
26644
- supplier_id?: string;
26652
+ supplier_data: {
26653
+ country_of_origin: Country$9;
26654
+ port_of_origin: string;
26655
+ supplier_id: string;
26645
26656
  supplier_name?: string;
26646
- factory_id?: string;
26657
+ factory_id: string;
26647
26658
  };
26648
26659
  buying_and_size_curve?: {
26649
26660
  direct?: string;
@@ -26718,7 +26729,7 @@ interface ProductDraft {
26718
26729
  developement_colourway_id: string;
26719
26730
  colour_id: string;
26720
26731
  style_id: string;
26721
- season_name?: string;
26732
+ season_name: string;
26722
26733
  drop_name: ("January" | "February" | "March" | "April" | "May" | "June" | "July" | "August" | "September" | "October" | "November" | "December" | "Carryover");
26723
26734
  development_style_id?: string;
26724
26735
  stock_type: string;
@@ -26728,58 +26739,58 @@ interface ProductDraft {
26728
26739
  reprocess_method?: (string | null);
26729
26740
  is_carry_over: boolean;
26730
26741
  image_url: string;
26731
- attributes?: {
26732
- product_type?: string;
26733
- product_category?: string;
26734
- product_subcategory?: string;
26735
- division?: ("Women" | null);
26736
- care_instructions?: string;
26737
- range?: (("Main Collection" | "Seasonal") | null);
26738
- main_fibre?: string;
26739
- size_range?: string;
26740
- sizes?: string;
26741
- occasion?: string;
26742
- strategy_type?: string;
26743
- pattern_name?: string;
26744
- neckline?: string;
26745
- sleeve_length?: (string | null);
26746
- leg_length?: (string | null);
26747
- heel_height?: (string | null);
26748
- heel_shape?: string;
26749
- toe_shape?: string;
26750
- handle_straps?: string;
26751
- fastening?: string;
26752
- sole_code?: string;
26753
- fashionability?: ("Core" | null);
26742
+ attributes: {
26743
+ product_type: string;
26744
+ product_category: string;
26745
+ product_subcategory: string;
26746
+ division: ("Women" | null);
26747
+ care_instructions: string;
26748
+ range: (("Main Collection" | "Seasonal") | null);
26749
+ main_fibre: string;
26750
+ size_range: string;
26751
+ sizes: string;
26752
+ occasion: string;
26753
+ strategy_type: string;
26754
+ pattern_name: string;
26755
+ neckline: string;
26756
+ sleeve_length: (string | null);
26757
+ leg_length: (string | null);
26758
+ heel_height: (string | null);
26759
+ heel_shape: string;
26760
+ toe_shape: string;
26761
+ handle_straps: string;
26762
+ fastening: string;
26763
+ sole_code: string;
26764
+ fashionability: ("Core" | null);
26754
26765
  fashion_type?: string;
26755
26766
  development_type?: string;
26756
- weight?: (string | null);
26757
- average_weight_grams?: number;
26767
+ weight: (string | null);
26768
+ average_weight_grams: number;
26758
26769
  extra_selling_point?: string;
26759
- length_measurement?: (string | null);
26760
- fabric_composition_footwear?: string;
26770
+ length_measurement: (string | null);
26771
+ fabric_composition_footwear: string;
26761
26772
  };
26762
- cost?: {
26763
- retail_price?: Money$9;
26764
- current_cost?: Money$9;
26765
- moq?: number;
26766
- finishing_cost?: Money$9;
26767
- other_costs?: Money$9;
26773
+ cost: {
26774
+ retail_price: Money$9;
26775
+ current_cost: Money$9;
26776
+ moq: number;
26777
+ finishing_cost: Money$9;
26778
+ other_costs: Money$9;
26768
26779
  commission?: Money$9;
26769
- freight_rate?: Money$9;
26770
- duty_rate?: Money$9;
26771
- commodity_code_ref?: string;
26780
+ freight_rate: Money$9;
26781
+ duty_rate: Money$9;
26782
+ commodity_code_ref: string;
26772
26783
  };
26773
26784
  payment_terms?: {
26774
26785
  supplier_payment_terms?: (string | null);
26775
26786
  supplier_inco_terms?: string;
26776
26787
  };
26777
- supplier_data?: {
26778
- country_of_origin?: Country$8;
26779
- port_of_origin?: string;
26780
- supplier_id?: string;
26788
+ supplier_data: {
26789
+ country_of_origin: Country$8;
26790
+ port_of_origin: string;
26791
+ supplier_id: string;
26781
26792
  supplier_name?: string;
26782
- factory_id?: string;
26793
+ factory_id: string;
26783
26794
  };
26784
26795
  buying_and_size_curve?: {
26785
26796
  direct?: string;
@@ -28685,11 +28696,162 @@ declare function validate<T>(payload: T, schema: JSONSchemaType<T>, options: {
28685
28696
  declare const sanitizeToString: DeepRedact;
28686
28697
  declare const sanitize: DeepRedact;
28687
28698
 
28699
+ type Opts = {
28700
+ workflowId: string;
28701
+ triggerId: string;
28702
+ url: string;
28703
+ envName: string;
28704
+ } | {
28705
+ workflowId: string;
28706
+ triggerId: string;
28707
+ url: string;
28708
+ };
28709
+ declare class Runtime {
28710
+ readonly workflowId: string;
28711
+ readonly triggerId: string;
28712
+ readonly envName: string;
28713
+ readonly systemEnvName: string;
28714
+ readonly runtimeUrl: string;
28715
+ constructor(opts: Opts);
28716
+ }
28717
+
28718
+ declare class EnvEngine extends Runtime {
28719
+ docRef: DocumentReference;
28720
+ private store;
28721
+ constructor(opts: Opts, firestore: Firestore);
28722
+ set(envs: Array<{
28723
+ name: string;
28724
+ value: string;
28725
+ }>): Promise<undefined>;
28726
+ private initializeIfNeeded;
28727
+ get<T extends ReadonlyArray<string>>(keys: T): Promise<{
28728
+ [K in T[number]]: string;
28729
+ }>;
28730
+ get(key: string): Promise<string>;
28731
+ }
28732
+
28733
+ declare class PubSubHelper extends Runtime {
28734
+ private pubSub;
28735
+ constructor(opts: Opts, pubSub: PubSub);
28736
+ createOrUpdate(opts: {
28737
+ topicName: string;
28738
+ dlq: boolean;
28739
+ retryLimit: number;
28740
+ retryDelay: number;
28741
+ ackDeadline: number;
28742
+ }): Promise<{
28743
+ topic: Topic;
28744
+ dlqTopic: Topic | null;
28745
+ dlqSubscription: Subscription | null;
28746
+ subscription: Subscription;
28747
+ }>;
28748
+ private findTopic;
28749
+ private ensureTopicExists;
28750
+ private getNameFromFullyQualifiedName;
28751
+ private ensureSubscribtionExists;
28752
+ private ensureDLQSubscriptionExists;
28753
+ deleteSubscription(subscriptionURN: string): Promise<any>;
28754
+ }
28755
+
28756
+ declare class SchedulerHelper extends Runtime {
28757
+ private extraQuery;
28758
+ private pubSubTarget;
28759
+ private pubSubProjectId;
28760
+ private schedulerLocationId;
28761
+ private schedulerClient;
28762
+ constructor(opts: Opts & {
28763
+ extraQuery: Record<string, string>;
28764
+ serviceAccount: string;
28765
+ defaultServiceAccount: string;
28766
+ pubSubTarget?: Topic | null;
28767
+ schedulerLocationId?: string | null;
28768
+ }, schedulerClient: CloudSchedulerClient);
28769
+ get locationIds(): string[];
28770
+ getTarget(): {
28771
+ pubsubTarget: {
28772
+ topicName: string;
28773
+ data: Buffer<ArrayBuffer>;
28774
+ };
28775
+ httpTarget?: undefined;
28776
+ } | {
28777
+ httpTarget: {
28778
+ uri: string;
28779
+ httpMethod: "POST";
28780
+ headers: {
28781
+ "Content-Type": string;
28782
+ };
28783
+ oidcToken: {
28784
+ serviceAccountEmail: string;
28785
+ audience: string;
28786
+ };
28787
+ };
28788
+ pubsubTarget?: undefined;
28789
+ };
28790
+ create({ schedule, timezone }: {
28791
+ schedule: string;
28792
+ timezone: string;
28793
+ }): Promise<{
28794
+ status: _google_cloud_scheduler_build_protos_protos.google.rpc.IStatus | null | undefined;
28795
+ state: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.Job.State | "STATE_UNSPECIFIED" | "ENABLED" | "PAUSED" | "DISABLED" | "UPDATE_FAILED" | null | undefined;
28796
+ name: string | null | undefined;
28797
+ httpTarget: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.IHttpTarget | null | undefined;
28798
+ pubsubTarget: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.IPubsubTarget | null | undefined;
28799
+ }>;
28800
+ update({ schedule, timezone }: {
28801
+ schedule: string;
28802
+ timezone: string;
28803
+ }): Promise<{
28804
+ status: _google_cloud_scheduler_build_protos_protos.google.rpc.IStatus | null | undefined;
28805
+ state: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.Job.State | "STATE_UNSPECIFIED" | "ENABLED" | "PAUSED" | "DISABLED" | "UPDATE_FAILED" | null | undefined;
28806
+ name: string | null | undefined;
28807
+ httpTarget: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.IHttpTarget | null | undefined;
28808
+ pubsubTarget: _google_cloud_scheduler_build_protos_protos.google.cloud.scheduler.v1.IPubsubTarget | null | undefined;
28809
+ }>;
28810
+ delete(): Promise<any>;
28811
+ }
28812
+
28813
+ declare class Secrets extends Runtime {
28814
+ private secretsManagerClient;
28815
+ constructor(opts: Opts, secretsManagerClient: SecretManagerServiceClient);
28816
+ getSecret(name: string): Promise<string>;
28817
+ }
28818
+
28819
+ declare class JWKSHelper extends Runtime {
28820
+ private firestore;
28821
+ constructor(opts: Opts, firestore: Firestore);
28822
+ validateAuthorizationHeader(authorizationHeader: string, expectedServiceAccount?: string | null): Promise<boolean>;
28823
+ getKey(keyId: string): Promise<{
28824
+ kid: string;
28825
+ } | undefined>;
28826
+ private fetchJWKS;
28827
+ }
28828
+
28829
+ declare const isPubSubRequest: (headers: Record<string, string>) => boolean;
28830
+ declare const isCronMessage: (headers: Record<string, string>) => boolean;
28831
+ declare const validateGoogleAuth: (opts: Opts & {
28832
+ serviceAccount?: string | null;
28833
+ }, headers: Record<string, string>, firestore: Firestore) => Promise<void>;
28834
+
28835
+ type index_EnvEngine = EnvEngine;
28836
+ declare const index_EnvEngine: typeof EnvEngine;
28837
+ type index_JWKSHelper = JWKSHelper;
28838
+ declare const index_JWKSHelper: typeof JWKSHelper;
28839
+ type index_PubSubHelper = PubSubHelper;
28840
+ declare const index_PubSubHelper: typeof PubSubHelper;
28841
+ type index_Runtime = Runtime;
28842
+ declare const index_Runtime: typeof Runtime;
28843
+ type index_SchedulerHelper = SchedulerHelper;
28844
+ declare const index_SchedulerHelper: typeof SchedulerHelper;
28845
+ type index_Secrets = Secrets;
28846
+ declare const index_Secrets: typeof Secrets;
28847
+ declare const index_isCronMessage: typeof isCronMessage;
28848
+ declare const index_isPubSubRequest: typeof isPubSubRequest;
28688
28849
  declare const index_sanitize: typeof sanitize;
28689
28850
  declare const index_sanitizeToString: typeof sanitizeToString;
28690
28851
  declare const index_validate: typeof validate;
28852
+ declare const index_validateGoogleAuth: typeof validateGoogleAuth;
28691
28853
  declare namespace index {
28692
- export { index_sanitize as sanitize, index_sanitizeToString as sanitizeToString, index_validate as validate };
28854
+ export { index_EnvEngine as EnvEngine, index_JWKSHelper as JWKSHelper, index_PubSubHelper as PubSubHelper, index_Runtime as Runtime, index_SchedulerHelper as SchedulerHelper, index_Secrets as Secrets, index_isCronMessage as isCronMessage, index_isPubSubRequest as isPubSubRequest, index_sanitize as sanitize, index_sanitizeToString as sanitizeToString, index_validate as validate, index_validateGoogleAuth as validateGoogleAuth };
28693
28855
  }
28694
28856
 
28695
28857
  export { index as lib, index$9 as schema, index$1 as types };