@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.
- package/LICENSE.txt +201 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/main.mjs +7 -5
- package/dist/main.mjs.map +1 -1
- package/dist/{src-Bgvuhcfk.mjs → src-YBU_KSf5.mjs} +272 -273
- package/dist/src-YBU_KSf5.mjs.map +1 -0
- package/package.json +17 -17
- package/src/create-table.ts +6 -1
- package/src/main.ts +8 -2
- package/src/resources/carts/row.ts +59 -35
- package/src/resources/customers/row.ts +67 -39
- package/src/resources/orders/row.ts +242 -116
- package/src/resources/products/row.ts +72 -42
- package/src/resources/refunds/row.ts +84 -44
- package/src/resources/shared.ts +77 -70
- package/src/start.ts +2 -2
- package/dist/src-Bgvuhcfk.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Iceberg } from "@useairfoil/connector-kit";
|
|
2
2
|
import * as Schema from "effect/Schema";
|
|
3
3
|
|
|
4
|
-
import {
|
|
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(
|
|
35
|
-
legacyResourceId: Schema.String.pipe(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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(
|
|
43
|
-
kind: TransactionKindSchema.pipe(
|
|
44
|
-
status: TransactionStatusSchema.pipe(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
75
|
+
Schema.annotateKey({ description: "Time when the transaction was processed." }),
|
|
56
76
|
),
|
|
57
|
-
})
|
|
58
|
-
).pipe(
|
|
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(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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.",
|
package/src/resources/shared.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
65
|
+
export const attributes = Schema.Array(
|
|
29
66
|
Schema.Struct({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export
|
|
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.
|
|
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
|
|
50
|
+
).pipe(Command.withDescription("Run the connector"));
|