@useairfoil/producer-shopify 0.2.1 → 0.2.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.
@@ -1,7 +1,7 @@
1
1
  import { Iceberg } from "@useairfoil/connector-kit";
2
2
  import * as Schema from "effect/Schema";
3
3
 
4
- import { field, moneyBag } from "../shared";
4
+ import { moneyBag } from "../shared";
5
5
 
6
6
  export const TransactionKindSchema = Schema.Literals([
7
7
  "SALE",
@@ -31,63 +31,103 @@ export const RestockTypeSchema = Schema.Literals([
31
31
  ]);
32
32
 
33
33
  export const RefundSchema = Schema.Struct({
34
- id: Schema.String.pipe(field(1, "Unique refund identifier.")),
35
- legacyResourceId: Schema.String.pipe(field(2, "Numeric refund identifier stored as text.")),
36
- orderId: Schema.String.pipe(field(3, "Refunded order identifier.")),
37
- note: Schema.NullOr(Schema.String).pipe(field(4, "Refund note.")),
38
- createdAt: Schema.NullOr(Schema.Date).pipe(field(5, "Time when the refund was created.")),
39
- processedAt: Schema.Date.pipe(field(6, "Time when the refund was processed.")),
34
+ id: Schema.String.pipe(Schema.annotateKey({ description: "Unique refund identifier." })),
35
+ legacyResourceId: Schema.String.pipe(
36
+ Schema.annotateKey({ description: "Numeric refund identifier stored as text." }),
37
+ ),
38
+ orderId: Schema.String.pipe(Schema.annotateKey({ description: "Refunded order identifier." })),
39
+ note: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Refund note." })),
40
+ createdAt: Schema.NullOr(Schema.Date).pipe(
41
+ Schema.annotateKey({ description: "Time when the refund was created." }),
42
+ ),
43
+ processedAt: Schema.Date.pipe(
44
+ Schema.annotateKey({ description: "Time when the refund was processed." }),
45
+ ),
40
46
  transactions: Schema.Array(
41
47
  Schema.Struct({
42
- id: Schema.String.pipe(field(101, "Unique transaction identifier.")),
43
- kind: TransactionKindSchema.pipe(field(102, "Kind of transaction.")),
44
- status: TransactionStatusSchema.pipe(field(103, "Status reported for the transaction.")),
45
- amount: Schema.String.pipe(field(104, "Amount in the customer currency.")),
46
- currencyCode: Schema.String.pipe(field(105, "Customer currency code.")),
47
- gateway: Schema.NullOr(Schema.String).pipe(field(106, "Payment gateway.")),
48
- test: Schema.Boolean.pipe(field(107, "Whether the transaction is a test.")),
49
- errorCode: Schema.NullOr(Schema.String).pipe(field(108, "Gateway error code.")),
48
+ id: Schema.String.pipe(Schema.annotateKey({ description: "Unique transaction identifier." })),
49
+ kind: TransactionKindSchema.pipe(Schema.annotateKey({ description: "Kind of transaction." })),
50
+ status: TransactionStatusSchema.pipe(
51
+ Schema.annotateKey({ description: "Status reported for the transaction." }),
52
+ ),
53
+ amount: Schema.String.pipe(
54
+ Schema.annotateKey({ description: "Amount in the customer currency." }),
55
+ ),
56
+ currencyCode: Schema.String.pipe(
57
+ Schema.annotateKey({ description: "Customer currency code." }),
58
+ ),
59
+ gateway: Schema.NullOr(Schema.String).pipe(
60
+ Schema.annotateKey({ description: "Payment gateway." }),
61
+ ),
62
+ test: Schema.Boolean.pipe(
63
+ Schema.annotateKey({ description: "Whether the transaction is a test." }),
64
+ ),
65
+ errorCode: Schema.NullOr(Schema.String).pipe(
66
+ Schema.annotateKey({ description: "Gateway error code." }),
67
+ ),
50
68
  parentTransactionId: Schema.NullOr(Schema.String).pipe(
51
- field(109, "Transaction this one refunds."),
69
+ Schema.annotateKey({ description: "Transaction this one refunds." }),
70
+ ),
71
+ createdAt: Schema.Date.pipe(
72
+ Schema.annotateKey({ description: "Time when the transaction was created." }),
52
73
  ),
53
- createdAt: Schema.Date.pipe(field(110, "Time when the transaction was created.")),
54
74
  processedAt: Schema.NullOr(Schema.Date).pipe(
55
- field(111, "Time when the transaction was processed."),
75
+ Schema.annotateKey({ description: "Time when the transaction was processed." }),
56
76
  ),
57
- }).annotate({ fieldId: 100 }),
58
- ).pipe(field(7, "Transactions that move the refunded money.")),
77
+ }),
78
+ ).pipe(Schema.annotateKey({ description: "Transactions that move the refunded money." })),
59
79
  refundLineItems: Schema.Array(
60
80
  Schema.Struct({
61
- id: Schema.NullOr(Schema.String).pipe(field(201, "Unique refund line item identifier.")),
62
- lineItemId: Schema.String.pipe(field(202, "Refunded order line item identifier.")),
63
- quantity: Schema.Int.pipe(field(203, "Quantity refunded.")),
64
- restockType: RestockTypeSchema.pipe(field(204, "How the items were restocked.")),
65
- locationId: Schema.NullOr(Schema.String).pipe(field(205, "Restock location identifier.")),
66
- subtotalSet: moneyBag(210).pipe(field(206, "Refunded subtotal.")),
67
- totalTaxSet: moneyBag(220).pipe(field(207, "Refunded tax.")),
68
- }).annotate({ fieldId: 200 }),
69
- ).pipe(field(8, "Refunded order line items.")),
81
+ id: Schema.NullOr(Schema.String).pipe(
82
+ Schema.annotateKey({ description: "Unique refund line item identifier." }),
83
+ ),
84
+ lineItemId: Schema.String.pipe(
85
+ Schema.annotateKey({ description: "Refunded order line item identifier." }),
86
+ ),
87
+ quantity: Schema.Int.pipe(Schema.annotateKey({ description: "Quantity refunded." })),
88
+ restockType: RestockTypeSchema.pipe(
89
+ Schema.annotateKey({ description: "How the items were restocked." }),
90
+ ),
91
+ locationId: Schema.NullOr(Schema.String).pipe(
92
+ Schema.annotateKey({ description: "Restock location identifier." }),
93
+ ),
94
+ subtotalSet: moneyBag.pipe(Schema.annotateKey({ description: "Refunded subtotal." })),
95
+ totalTaxSet: moneyBag.pipe(Schema.annotateKey({ description: "Refunded tax." })),
96
+ }),
97
+ ).pipe(Schema.annotateKey({ description: "Refunded order line items." })),
70
98
  refundShippingLines: Schema.Array(
71
99
  Schema.Struct({
72
- id: Schema.String.pipe(field(301, "Unique refund shipping line identifier.")),
73
- shippingLineId: Schema.NullOr(Schema.String).pipe(field(302, "Refunded shipping line.")),
74
- subtotalAmountSet: moneyBag(310).pipe(field(303, "Refunded shipping amount.")),
75
- }).annotate({ fieldId: 300 }),
76
- ).pipe(field(9, "Refunded shipping.")),
100
+ id: Schema.String.pipe(
101
+ Schema.annotateKey({ description: "Unique refund shipping line identifier." }),
102
+ ),
103
+ shippingLineId: Schema.NullOr(Schema.String).pipe(
104
+ Schema.annotateKey({ description: "Refunded shipping line." }),
105
+ ),
106
+ subtotalAmountSet: moneyBag.pipe(
107
+ Schema.annotateKey({ description: "Refunded shipping amount." }),
108
+ ),
109
+ }),
110
+ ).pipe(Schema.annotateKey({ description: "Refunded shipping." })),
77
111
  orderAdjustments: Schema.Array(
78
112
  Schema.Struct({
79
- id: Schema.String.pipe(field(401, "Unique order adjustment identifier.")),
80
- reason: Schema.NullOr(Schema.String).pipe(field(402, "Reason for the adjustment.")),
81
- amountSet: moneyBag(410).pipe(field(403, "Adjustment amount.")),
82
- taxAmountSet: moneyBag(420).pipe(field(404, "Tax on the adjustment.")),
83
- }).annotate({ fieldId: 400 }),
84
- ).pipe(field(10, "Refund discrepancy adjustments.")),
113
+ id: Schema.String.pipe(
114
+ Schema.annotateKey({ description: "Unique order adjustment identifier." }),
115
+ ),
116
+ reason: Schema.NullOr(Schema.String).pipe(
117
+ Schema.annotateKey({ description: "Reason for the adjustment." }),
118
+ ),
119
+ amountSet: moneyBag.pipe(Schema.annotateKey({ description: "Adjustment amount." })),
120
+ taxAmountSet: moneyBag.pipe(Schema.annotateKey({ description: "Tax on the adjustment." })),
121
+ }),
122
+ ).pipe(Schema.annotateKey({ description: "Refund discrepancy adjustments." })),
85
123
  duties: Schema.Array(
86
124
  Schema.Struct({
87
- dutyId: Schema.NullOr(Schema.String).pipe(field(501, "Refunded duty identifier.")),
88
- amountSet: moneyBag(510).pipe(field(502, "Refunded duty amount.")),
89
- }).annotate({ fieldId: 500 }),
90
- ).pipe(field(11, "Refunded duties.")),
125
+ dutyId: Schema.NullOr(Schema.String).pipe(
126
+ Schema.annotateKey({ description: "Refunded duty identifier." }),
127
+ ),
128
+ amountSet: moneyBag.pipe(Schema.annotateKey({ description: "Refunded duty amount." })),
129
+ }),
130
+ ).pipe(Schema.annotateKey({ description: "Refunded duties." })),
91
131
  })
92
132
  .annotate({
93
133
  description: "Refunds on orders in a Shopify store.",
@@ -1,10 +1,6 @@
1
- import { Iceberg } from "@useairfoil/connector-kit";
2
1
  import { SchemaTransformation } from "effect";
3
2
  import * as Schema from "effect/Schema";
4
3
 
5
- export const field = (fieldId: number, description: string) =>
6
- Iceberg.field(fieldId, { description });
7
-
8
4
  export const PageInfoSchema = Schema.Struct({
9
5
  hasNextPage: Schema.Boolean,
10
6
  endCursor: Schema.NullOr(Schema.String),
@@ -23,75 +19,86 @@ export const splitTags = (value: string): ReadonlyArray<string> =>
23
19
  .map((tag) => tag.trim())
24
20
  .filter((tag) => tag.length > 0);
25
21
 
26
- // Each row helper takes the first field ID of its block.
22
+ export const moneyBag = Schema.Struct({
23
+ shopMoney: Schema.Struct({
24
+ amount: Schema.String.pipe(Schema.annotateKey({ description: "Amount in the shop currency." })),
25
+ currencyCode: Schema.String.pipe(Schema.annotateKey({ description: "Shop currency code." })),
26
+ }).pipe(Schema.annotateKey({ description: "Amount in the shop currency." })),
27
+ presentmentMoney: Schema.Struct({
28
+ amount: Schema.String.pipe(
29
+ Schema.annotateKey({ description: "Amount in the customer currency." }),
30
+ ),
31
+ currencyCode: Schema.String.pipe(
32
+ Schema.annotateKey({ description: "Customer currency code." }),
33
+ ),
34
+ }).pipe(Schema.annotateKey({ description: "Amount in the customer currency." })),
35
+ });
36
+
37
+ export const address = Schema.Struct({
38
+ firstName: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "First name." })),
39
+ lastName: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Last name." })),
40
+ name: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Full name." })),
41
+ company: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Company name." })),
42
+ address1: Schema.NullOr(Schema.String).pipe(
43
+ Schema.annotateKey({ description: "First address line." }),
44
+ ),
45
+ address2: Schema.NullOr(Schema.String).pipe(
46
+ Schema.annotateKey({ description: "Second address line." }),
47
+ ),
48
+ city: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "City." })),
49
+ province: Schema.NullOr(Schema.String).pipe(
50
+ Schema.annotateKey({ description: "Province or state." }),
51
+ ),
52
+ provinceCode: Schema.NullOr(Schema.String).pipe(
53
+ Schema.annotateKey({ description: "Province or state code." }),
54
+ ),
55
+ country: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Country." })),
56
+ countryCode: Schema.NullOr(Schema.String).pipe(
57
+ Schema.annotateKey({ description: "Two-letter country code." }),
58
+ ),
59
+ zip: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Postal code." })),
60
+ phone: Schema.NullOr(Schema.String).pipe(Schema.annotateKey({ description: "Phone number." })),
61
+ latitude: Schema.NullOr(Schema.Finite).pipe(Schema.annotateKey({ description: "Latitude." })),
62
+ longitude: Schema.NullOr(Schema.Finite).pipe(Schema.annotateKey({ description: "Longitude." })),
63
+ });
27
64
 
28
- export const moneyBag = (baseId: number) =>
65
+ export const attributes = Schema.Array(
29
66
  Schema.Struct({
30
- shopMoney: Schema.Struct({
31
- amount: Schema.String.pipe(field(baseId + 3, "Amount in the shop currency.")),
32
- currencyCode: Schema.String.pipe(field(baseId + 4, "Shop currency code.")),
33
- }).pipe(field(baseId + 1, "Amount in the shop currency.")),
34
- presentmentMoney: Schema.Struct({
35
- amount: Schema.String.pipe(field(baseId + 5, "Amount in the customer currency.")),
36
- currencyCode: Schema.String.pipe(field(baseId + 6, "Customer currency code.")),
37
- }).pipe(field(baseId + 2, "Amount in the customer currency.")),
38
- });
39
-
40
- export const address = (baseId: number) =>
67
+ key: Schema.String.pipe(Schema.annotateKey({ description: "Attribute name." })),
68
+ value: Schema.NullOr(Schema.String).pipe(
69
+ Schema.annotateKey({ description: "Attribute value." }),
70
+ ),
71
+ }),
72
+ );
73
+
74
+ export const taxLines = Schema.Array(
41
75
  Schema.Struct({
42
- firstName: Schema.NullOr(Schema.String).pipe(field(baseId + 1, "First name.")),
43
- lastName: Schema.NullOr(Schema.String).pipe(field(baseId + 2, "Last name.")),
44
- name: Schema.NullOr(Schema.String).pipe(field(baseId + 3, "Full name.")),
45
- company: Schema.NullOr(Schema.String).pipe(field(baseId + 4, "Company name.")),
46
- address1: Schema.NullOr(Schema.String).pipe(field(baseId + 5, "First address line.")),
47
- address2: Schema.NullOr(Schema.String).pipe(field(baseId + 6, "Second address line.")),
48
- city: Schema.NullOr(Schema.String).pipe(field(baseId + 7, "City.")),
49
- province: Schema.NullOr(Schema.String).pipe(field(baseId + 8, "Province or state.")),
50
- provinceCode: Schema.NullOr(Schema.String).pipe(field(baseId + 9, "Province or state code.")),
51
- country: Schema.NullOr(Schema.String).pipe(field(baseId + 10, "Country.")),
52
- countryCode: Schema.NullOr(Schema.String).pipe(field(baseId + 11, "Two-letter country code.")),
53
- zip: Schema.NullOr(Schema.String).pipe(field(baseId + 12, "Postal code.")),
54
- phone: Schema.NullOr(Schema.String).pipe(field(baseId + 13, "Phone number.")),
55
- latitude: Schema.NullOr(Schema.Finite).pipe(field(baseId + 14, "Latitude.")),
56
- longitude: Schema.NullOr(Schema.Finite).pipe(field(baseId + 15, "Longitude.")),
57
- });
58
-
59
- export const attributes = (baseId: number) =>
60
- Schema.Array(
61
- Schema.Struct({
62
- key: Schema.String.pipe(field(baseId + 2, "Attribute name.")),
63
- value: Schema.NullOr(Schema.String).pipe(field(baseId + 3, "Attribute value.")),
64
- }).annotate({ fieldId: baseId + 1 }),
65
- );
66
-
67
- export const taxLines = (baseId: number) =>
68
- Schema.Array(
69
- Schema.Struct({
70
- title: Schema.String.pipe(field(baseId + 2, "Tax name.")),
71
- rate: Schema.NullOr(Schema.Finite).pipe(field(baseId + 3, "Tax rate as a fraction.")),
72
- priceSet: moneyBag(baseId + 10).pipe(field(baseId + 4, "Tax amount.")),
73
- }).annotate({ fieldId: baseId + 1 }),
74
- );
75
-
76
- export const discountAllocations = (baseId: number) =>
77
- Schema.Array(
78
- Schema.Struct({
79
- discountApplicationIndex: Schema.Int.pipe(
80
- field(baseId + 2, "Index of the order discount application."),
81
- ),
82
- amountSet: moneyBag(baseId + 10).pipe(field(baseId + 3, "Allocated discount amount.")),
83
- }).annotate({ fieldId: baseId + 1 }),
84
- );
85
-
86
- export type MoneyBag = Schema.Schema.Type<ReturnType<typeof moneyBag>>;
87
-
88
- export type Address = Schema.Schema.Type<ReturnType<typeof address>>;
89
-
90
- export type Attribute = Schema.Schema.Type<ReturnType<typeof attributes>>[number];
91
-
92
- export type TaxLine = Schema.Schema.Type<ReturnType<typeof taxLines>>[number];
93
-
94
- export type DiscountAllocation = Schema.Schema.Type<ReturnType<typeof discountAllocations>>[number];
76
+ title: Schema.String.pipe(Schema.annotateKey({ description: "Tax name." })),
77
+ rate: Schema.NullOr(Schema.Finite).pipe(
78
+ Schema.annotateKey({ description: "Tax rate as a fraction." }),
79
+ ),
80
+ priceSet: moneyBag.pipe(Schema.annotateKey({ description: "Tax amount." })),
81
+ }),
82
+ );
83
+
84
+ export const discountAllocations = Schema.Array(
85
+ Schema.Struct({
86
+ discountApplicationIndex: Schema.Int.pipe(
87
+ Schema.annotateKey({ description: "Index of the order discount application." }),
88
+ ),
89
+ amountSet: moneyBag.pipe(Schema.annotateKey({ description: "Allocated discount amount." })),
90
+ }),
91
+ );
92
+
93
+ export type MoneyBag = Schema.Schema.Type<typeof moneyBag>;
94
+
95
+ export type Address = Schema.Schema.Type<typeof address>;
96
+
97
+ export type Attribute = Schema.Schema.Type<typeof attributes>[number];
98
+
99
+ export type TaxLine = Schema.Schema.Type<typeof taxLines>[number];
100
+
101
+ export type DiscountAllocation = Schema.Schema.Type<typeof discountAllocations>[number];
95
102
 
96
103
  export const RestMoneyBagSchema = Schema.Struct({
97
104
  shop_money: Schema.Struct({ amount: Schema.String, currency_code: Schema.String }),
package/src/start.ts CHANGED
@@ -33,7 +33,7 @@ export const startCommand = Command.make("start", {}, () =>
33
33
  const entrypoint = yield* ShopifyConnector.ShopifyConnector;
34
34
 
35
35
  return yield* ConnectorApp.start(entrypoint, { port }).pipe(
36
- Effect.provide(Ingestor.layerWingsConfig(entrypoint)),
36
+ Effect.provide(Ingestor.layerArrowFlightConfig(entrypoint)),
37
37
  );
38
38
  }).pipe(
39
39
  Effect.annotateLogs({ component: "producer-shopify" }),
@@ -47,4 +47,4 @@ export const startCommand = Command.make("start", {}, () =>
47
47
  ),
48
48
  Effect.provide(RuntimeConfig.layerHosted()),
49
49
  ),
50
- ).pipe(Command.withDescription("Run the production connector against Wings"));
50
+ ).pipe(Command.withDescription("Run the connector"));