@friggframework/core 2.0.0--canary.690.08cd07e.0 → 2.0.0--canary.694.f66a64a.0
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/CLAUDE.md +0 -28
- package/README.md +0 -105
- package/application/commands/integration-commands.js +10 -20
- package/application/commands/scheduler-commands.js +7 -11
- package/application/commands/user-commands.js +5 -17
- package/application/index.js +2 -6
- package/core/Worker.js +7 -31
- package/core/create-handler.js +0 -9
- package/credential/repositories/credential-repository-documentdb.js +0 -34
- package/credential/repositories/credential-repository-interface.js +0 -15
- package/credential/repositories/credential-repository-mongo.js +0 -23
- package/credential/repositories/credential-repository-postgres.js +0 -28
- package/database/config.js +24 -48
- package/database/documentdb-utils.js +2 -2
- package/database/encryption/encryption-schema-registry.js +12 -93
- package/database/prisma.js +2 -4
- package/errors/index.js +4 -0
- package/errors/mapping-already-exists-error.js +14 -0
- package/generated/prisma-mongodb/edge.js +38 -33
- package/generated/prisma-mongodb/index-browser.js +35 -30
- package/generated/prisma-mongodb/index.d.ts +1880 -3191
- package/generated/prisma-mongodb/index.js +38 -33
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +50 -86
- package/generated/prisma-mongodb/wasm.js +38 -33
- package/generated/prisma-postgresql/edge.js +38 -33
- package/generated/prisma-postgresql/index-browser.js +35 -30
- package/generated/prisma-postgresql/index.d.ts +2050 -3390
- package/generated/prisma-postgresql/index.js +38 -33
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +48 -81
- package/generated/prisma-postgresql/wasm.js +38 -33
- package/handlers/WEBHOOKS.md +29 -0
- package/handlers/app-definition-loader.js +19 -128
- package/handlers/app-handler-helpers.js +3 -25
- package/handlers/backend-utils.js +25 -31
- package/handlers/middleware/admin-auth.js +1 -14
- package/handlers/routers/auth.js +10 -46
- package/handlers/routers/health.js +4 -13
- package/handlers/routers/integration-defined-routers.js +92 -144
- package/handlers/routers/integration-webhook-routers.js +64 -102
- package/handlers/workers/integration-defined-workers.js +2 -5
- package/handlers/workers/integration-triggers.js +25 -0
- package/index.js +3 -65
- package/infrastructure/scheduler/index.js +6 -19
- package/infrastructure/scheduler/recurrence.js +204 -0
- package/infrastructure/scheduler/scheduler-service-factory.js +7 -55
- package/integrations/data-defined/README.md +185 -0
- package/integrations/data-defined/canonical.js +11 -0
- package/integrations/data-defined/capabilities/acmeerp.capabilities.json +608 -0
- package/integrations/data-defined/capabilities/asana.capabilities.json +265 -0
- package/integrations/data-defined/capabilities/calendly.capabilities.json +385 -0
- package/integrations/data-defined/capabilities/docusign.capabilities.json +314 -0
- package/integrations/data-defined/capabilities/fathom.capabilities.json +228 -0
- package/integrations/data-defined/capabilities/github.capabilities.json +563 -0
- package/integrations/data-defined/capabilities/hubspot.capabilities.json +715 -0
- package/integrations/data-defined/capabilities/jira.capabilities.json +376 -0
- package/integrations/data-defined/capabilities/klaviyo.capabilities.json +475 -0
- package/integrations/data-defined/capabilities/linear.capabilities.json +324 -0
- package/integrations/data-defined/capabilities/netsuite.capabilities.json +491 -0
- package/integrations/data-defined/capabilities/notion.capabilities.json +208 -0
- package/integrations/data-defined/capabilities/phone.capabilities.json +470 -0
- package/integrations/data-defined/capabilities/pipedrive.capabilities.json +388 -0
- package/integrations/data-defined/capabilities/quickbooks.capabilities.json +615 -0
- package/integrations/data-defined/capabilities/salesforce.capabilities.json +507 -0
- package/integrations/data-defined/capabilities/shopify.capabilities.json +1082 -0
- package/integrations/data-defined/capabilities/slack.capabilities.json +363 -0
- package/integrations/data-defined/capabilities/stripe.capabilities.json +580 -0
- package/integrations/data-defined/capabilities/webflow.capabilities.json +196 -0
- package/integrations/data-defined/capabilities/zendesk.capabilities.json +409 -0
- package/integrations/data-defined/compile.js +80 -0
- package/integrations/data-defined/config-form.js +137 -0
- package/integrations/data-defined/data-defined-integration.js +417 -0
- package/integrations/data-defined/examples/acme-erp-quickbooks.definition.json +467 -0
- package/integrations/data-defined/examples/asana-slack.definition.json +220 -0
- package/integrations/data-defined/examples/calendly-salesforce.definition.json +459 -0
- package/integrations/data-defined/examples/docusign-salesforce.definition.json +305 -0
- package/integrations/data-defined/examples/fathom-hubspot-notion.definition.json +575 -0
- package/integrations/data-defined/examples/github-linear.definition.json +316 -0
- package/integrations/data-defined/examples/hubspot-slack.definition.json +409 -0
- package/integrations/data-defined/examples/klaviyo-hubspot.definition.json +339 -0
- package/integrations/data-defined/examples/phone-hubspot.definition.json +637 -0
- package/integrations/data-defined/examples/pipedrive-hubspot.definition.json +136 -0
- package/integrations/data-defined/examples/pipedrive-phone.definition.json +340 -0
- package/integrations/data-defined/examples/records/phone-hubspot.definition-version.json +652 -0
- package/integrations/data-defined/examples/records/phone-hubspot.integration.json +86 -0
- package/integrations/data-defined/examples/records/phone-hubspot.mappings.json +39 -0
- package/integrations/data-defined/examples/records/phone-hubspot.workflow-run.json +62 -0
- package/integrations/data-defined/examples/shopify-klaviyo.definition.json +488 -0
- package/integrations/data-defined/examples/shopify-netsuite.definition.json +622 -0
- package/integrations/data-defined/examples/stripe-quickbooks.definition.json +476 -0
- package/integrations/data-defined/examples/webflow-hubspot-slack.definition.json +262 -0
- package/integrations/data-defined/examples/zendesk-jira.definition.json +604 -0
- package/integrations/data-defined/expressions.js +225 -0
- package/integrations/data-defined/index.js +39 -0
- package/integrations/data-defined/interpreter.js +89 -0
- package/integrations/data-defined/manifests.js +125 -0
- package/integrations/data-defined/repositories/definition-version-repository.js +67 -0
- package/integrations/data-defined/repositories/workflow-run-repository.js +59 -0
- package/integrations/data-defined/router.js +97 -0
- package/integrations/data-defined/runtime.js +208 -0
- package/integrations/data-defined/schema/capability-manifest.v0.1.schema.json +377 -0
- package/integrations/data-defined/schema/installation.v0.1.schema.json +130 -0
- package/integrations/data-defined/schema/integration-definition.v0.1.schema.json +902 -0
- package/integrations/data-defined/schema/records.md +98 -0
- package/integrations/data-defined/schema-check.js +58 -0
- package/integrations/data-defined/scripts/validate.js +66 -0
- package/integrations/data-defined/steps.js +89 -0
- package/integrations/data-defined/transforms.js +91 -0
- package/integrations/data-defined/use-cases/definition-use-cases.js +187 -0
- package/integrations/data-defined/validate.js +384 -0
- package/integrations/data-defined/versioning.js +176 -0
- package/integrations/data-defined/webhooks.js +119 -0
- package/integrations/index.js +0 -1
- package/integrations/integration-base.js +117 -0
- package/integrations/integration-router.js +101 -131
- package/integrations/repositories/integration-mapping-repository-documentdb.js +50 -0
- package/integrations/repositories/integration-mapping-repository-interface.js +15 -0
- package/integrations/repositories/integration-mapping-repository-mongo.js +29 -0
- package/integrations/repositories/integration-mapping-repository-postgres.js +30 -0
- package/integrations/repositories/integration-mapping-repository.js +29 -0
- package/integrations/repositories/integration-repository-documentdb.js +9 -37
- package/integrations/repositories/integration-repository-interface.js +4 -17
- package/integrations/repositories/integration-repository-mongo.js +96 -64
- package/integrations/repositories/integration-repository-postgres.js +81 -63
- package/integrations/repositories/process-repository-mongo.js +1 -1
- package/integrations/tests/doubles/test-integration-repository.js +1 -12
- package/integrations/triggers.js +244 -0
- package/integrations/use-cases/create-integration.js +20 -55
- package/integrations/use-cases/get-integrations-for-user.js +40 -80
- package/integrations/use-cases/index.js +1 -7
- package/integrations/use-cases/run-trigger-tick.js +132 -0
- package/integrations/use-cases/run-trigger.js +77 -0
- package/integrations/utils/map-integration-dto.js +14 -43
- package/modules/index.js +0 -14
- package/modules/module-factory.js +0 -12
- package/modules/module.js +2 -53
- package/modules/repositories/module-repository-documentdb.js +6 -51
- package/modules/repositories/module-repository-interface.js +2 -19
- package/modules/repositories/module-repository-mongo.js +74 -67
- package/modules/repositories/module-repository-postgres.js +74 -66
- package/modules/repositories/module-repository.js +1 -2
- package/modules/requester/requester.js +5 -35
- package/modules/use-cases/get-entities-for-user.js +13 -26
- package/modules/use-cases/get-entity-options-by-id.js +4 -10
- package/modules/use-cases/get-entity-options-by-type.js +1 -1
- package/modules/use-cases/get-module-instance-from-type.js +1 -1
- package/modules/use-cases/get-module.js +4 -10
- package/modules/use-cases/process-authorization-callback.js +19 -53
- package/modules/use-cases/refresh-entity-options.js +4 -10
- package/modules/use-cases/test-module-auth.js +4 -10
- package/package.json +6 -6
- package/prisma-mongodb/schema.prisma +50 -86
- package/prisma-postgresql/migrations/20261018000000_add_data_defined_integrations/migration.sql +66 -0
- package/prisma-postgresql/schema.prisma +48 -81
- package/queues/index.js +0 -25
- package/queues/queuer-util.js +9 -2
- package/types/index.d.ts +0 -2
- package/user/repositories/user-repository-documentdb.js +2 -27
- package/user/repositories/user-repository-interface.js +0 -18
- package/user/repositories/user-repository-mongo.js +0 -24
- package/user/repositories/user-repository-postgres.js +0 -18
- package/user/use-cases/authenticate-user.js +1 -7
- package/user/use-cases/get-user-from-adopter-jwt.js +124 -95
- package/user/use-cases/get-user-from-x-frigg-headers.js +80 -83
- package/user/user.js +1 -64
- package/credential/use-cases/credential-operations-for-user.js +0 -202
- package/credential/use-cases/reauthorize-credential-for-user.js +0 -73
- package/database/organization-where.js +0 -18
- package/database/unique-violation.js +0 -25
- package/extensions/bootstrap-runner.js +0 -43
- package/extensions/extension-loader.js +0 -187
- package/extensions/index.js +0 -41
- package/extensions/initialize-app.js +0 -123
- package/extensions/route-mounter.js +0 -103
- package/extensions/schema-composer.js +0 -188
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +0 -216
- package/infrastructure/scheduler/scheduled-job-repository.js +0 -118
- package/integrations/repositories/integration-not-found.js +0 -14
- package/integrations/schedule-config.js +0 -80
- package/integrations/use-cases/dispatch-ongoing-syncs.js +0 -100
- package/integrations/use-cases/integration-operations-for-user.js +0 -256
- package/integrations/use-cases/resolve-integration-ownership.js +0 -177
- package/management-api/create-management-api-router.js +0 -49
- package/management-api/error-response.js +0 -116
- package/management-api/management-api-config.js +0 -151
- package/management-api/meta-router.js +0 -76
- package/management-api/openapi/build-openapi.js +0 -144
- package/management-api/openapi/components.js +0 -415
- package/management-api/openapi/v1-operations.js +0 -83
- package/management-api/openapi/v2-operations.js +0 -264
- package/management-api/route-registry.js +0 -411
- package/management-api/test-support/http-client.js +0 -39
- package/management-api/use-cases/get-management-api-meta.js +0 -57
- package/management-api/v1-deprecation.js +0 -120
- package/management-api/v2/create-v2-router.js +0 -85
- package/management-api/v2/dependencies.js +0 -281
- package/management-api/v2/dto.js +0 -143
- package/management-api/v2/handlers/authorization.js +0 -94
- package/management-api/v2/handlers/credentials.js +0 -33
- package/management-api/v2/handlers/entities.js +0 -77
- package/management-api/v2/handlers/integrations.js +0 -128
- package/management-api/v2/handlers/proxy.js +0 -34
- package/management-api/v2/request.js +0 -85
- package/management-api/v2/test-support/fake-dependencies.js +0 -103
- package/modules/domain/authorization-session.js +0 -144
- package/modules/entity-scope.js +0 -15
- package/modules/entity-type-registry.js +0 -311
- package/modules/proxy/proxy-bases.js +0 -169
- package/modules/proxy/proxy-errors.js +0 -31
- package/modules/proxy/proxy-path.js +0 -183
- package/modules/proxy/proxy-policy.js +0 -277
- package/modules/repositories/authorization-session-repository-documentdb.js +0 -112
- package/modules/repositories/authorization-session-repository-factory.js +0 -31
- package/modules/repositories/authorization-session-repository-interface.js +0 -47
- package/modules/repositories/authorization-session-repository-prisma.js +0 -87
- package/modules/repositories/entity-not-found.js +0 -18
- package/modules/requester/proxy-request.js +0 -245
- package/modules/scope-config.js +0 -192
- package/modules/scope-policy.js +0 -112
- package/modules/scope-resolution.js +0 -288
- package/modules/scope-visibility.js +0 -247
- package/modules/tests/doubles/in-memory-authorization-session-repository.js +0 -45
- package/modules/tests/doubles/ownership-matching.js +0 -18
- package/modules/use-cases/authorize-entity-for-user.js +0 -61
- package/modules/use-cases/create-entity-from-credential.js +0 -113
- package/modules/use-cases/entity-operations-for-user.js +0 -162
- package/modules/use-cases/entity-types.js +0 -139
- package/modules/use-cases/execute-entity-proxy-request.js +0 -331
- package/modules/use-cases/get-authorization-requirements.js +0 -100
- package/modules/use-cases/get-entity-module-for-user.js +0 -113
- package/modules/use-cases/manage-access.js +0 -21
- package/modules/use-cases/multi-step-authorization.js +0 -329
- package/prisma-postgresql/migrations/20261003000000_add_authorization_session/migration.sql +0 -28
- package/prisma-postgresql/migrations/20261015000000_add_organization_membership/migration.sql +0 -26
- package/prisma-postgresql/migrations/20261016000000_add_entity_integration_organization/migration.sql +0 -25
- package/prisma-postgresql/migrations/20261017000000_add_scheduled_job/migration.sql +0 -28
- package/providers/index.js +0 -23
- package/providers/resolve-provider.js +0 -93
- package/providers/runtime-detection.js +0 -124
- package/queues/providers/index.js +0 -11
- package/queues/providers/netlify-background-provider.js +0 -150
- package/queues/providers/qstash-queue-provider.js +0 -219
- package/queues/providers/sqs-queue-provider.js +0 -70
- package/queues/queue-client-interface.js +0 -55
- package/queues/queue-message-auth.js +0 -193
- package/queues/queue-provider-factory.js +0 -101
- package/queues/queue-provider.js +0 -65
- package/queues/sqs-queue-client.js +0 -81
- package/types/modules/index.d.ts +0 -214
- package/types/user/index.d.ts +0 -134
- package/user/adopter-jwt-config.js +0 -177
- package/user/adopter-jwt-errors.js +0 -59
- package/user/adopter-token-verifier.js +0 -122
- package/user/app-user-helpers.js +0 -97
- package/user/create-user-authentication.js +0 -64
- package/user/membership.js +0 -51
- package/user/repositories/organization-membership-record.js +0 -19
- package/user/repositories/organization-membership-repository-documentdb.js +0 -106
- package/user/repositories/organization-membership-repository-factory.js +0 -42
- package/user/repositories/organization-membership-repository-interface.js +0 -57
- package/user/repositories/organization-membership-repository-mongo.js +0 -13
- package/user/repositories/organization-membership-repository-postgres.js +0 -29
- package/user/repositories/organization-membership-repository-prisma.js +0 -81
- package/user/tests/doubles/adopter-jwt-fixtures.js +0 -220
- package/user/use-cases/ensure-organization-membership.js +0 -92
- package/user/use-cases/find-individual-users-by-organization.js +0 -54
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://friggframework.org/schemas/integration-definition/v0.1.json",
|
|
3
|
+
"schemaVersion": "0.1",
|
|
4
|
+
"id": "shopify-netsuite",
|
|
5
|
+
"version": "2.2.0",
|
|
6
|
+
"display": {
|
|
7
|
+
"label": "Shopify \u2192 NetSuite",
|
|
8
|
+
"description": "Paid Shopify orders become NetSuite sales orders, customers follow them, NetSuite fulfillments write tracking back to Shopify, refunds become credit memos, and low stock is announced in Slack.",
|
|
9
|
+
"category": "ERP",
|
|
10
|
+
"tags": [
|
|
11
|
+
"ecommerce",
|
|
12
|
+
"erp",
|
|
13
|
+
"order-to-cash",
|
|
14
|
+
"inventory"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"modules": {
|
|
18
|
+
"shopify": {
|
|
19
|
+
"module": "shopify",
|
|
20
|
+
"version": "^3.1"
|
|
21
|
+
},
|
|
22
|
+
"netsuite": {
|
|
23
|
+
"module": "netsuite",
|
|
24
|
+
"version": "^1.2"
|
|
25
|
+
},
|
|
26
|
+
"slack": {
|
|
27
|
+
"module": "slack",
|
|
28
|
+
"version": "^2.0"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"settings": {
|
|
32
|
+
"subsidiary": {
|
|
33
|
+
"type": "option",
|
|
34
|
+
"options": "netsuite.subsidiary",
|
|
35
|
+
"label": "NetSuite subsidiary for new customers and orders",
|
|
36
|
+
"required": true
|
|
37
|
+
},
|
|
38
|
+
"location": {
|
|
39
|
+
"type": "option",
|
|
40
|
+
"options": "netsuite.location",
|
|
41
|
+
"label": "Fulfil Shopify orders from",
|
|
42
|
+
"required": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"syncs": [
|
|
46
|
+
{
|
|
47
|
+
"id": "customers",
|
|
48
|
+
"label": "Customers",
|
|
49
|
+
"description": "Every Shopify customer exists in NetSuite as an individual customer, matched by email.",
|
|
50
|
+
"source": "shopify.customer",
|
|
51
|
+
"target": "netsuite.customer",
|
|
52
|
+
"direction": "one_way",
|
|
53
|
+
"identity": {
|
|
54
|
+
"match": [
|
|
55
|
+
{
|
|
56
|
+
"source": "email",
|
|
57
|
+
"target": "email",
|
|
58
|
+
"transform": "lowercase",
|
|
59
|
+
"key": "email"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"onAmbiguous": "first"
|
|
63
|
+
},
|
|
64
|
+
"mapping": [
|
|
65
|
+
{
|
|
66
|
+
"source": "first_name",
|
|
67
|
+
"target": "firstName"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"source": "last_name",
|
|
71
|
+
"target": "lastName"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"source": "email",
|
|
75
|
+
"target": "email",
|
|
76
|
+
"transform": "lowercase"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"source": "phone",
|
|
80
|
+
"target": "phone",
|
|
81
|
+
"transform": "to_e164_phone"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"source": "default_address.company",
|
|
85
|
+
"target": "companyName"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"source": "id",
|
|
89
|
+
"target": "externalId",
|
|
90
|
+
"transform": "none"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"filter": "$.record.email exists",
|
|
94
|
+
"backfill": {
|
|
95
|
+
"trigger": "userAction",
|
|
96
|
+
"pageSize": 250
|
|
97
|
+
},
|
|
98
|
+
"ongoing": {
|
|
99
|
+
"mode": "webhook"
|
|
100
|
+
},
|
|
101
|
+
"default": "on"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "orders",
|
|
105
|
+
"label": "Orders",
|
|
106
|
+
"description": "Paid orders become sales orders. The header is mapped here; lines and the customer are filled in by the \"Sales order lines\" workflow.",
|
|
107
|
+
"source": "shopify.order",
|
|
108
|
+
"target": "netsuite.salesOrder",
|
|
109
|
+
"direction": "one_way",
|
|
110
|
+
"identity": {
|
|
111
|
+
"match": [
|
|
112
|
+
{
|
|
113
|
+
"source": "name",
|
|
114
|
+
"target": "otherRefNum",
|
|
115
|
+
"key": "orderNumber"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"onAmbiguous": "skip"
|
|
119
|
+
},
|
|
120
|
+
"mapping": [
|
|
121
|
+
{
|
|
122
|
+
"source": "name",
|
|
123
|
+
"target": "otherRefNum"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"source": "id",
|
|
127
|
+
"target": "externalId"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"source": "created_at",
|
|
131
|
+
"target": "tranDate",
|
|
132
|
+
"transform": "to_iso_date"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"source": "email",
|
|
136
|
+
"target": "email",
|
|
137
|
+
"transform": "lowercase"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"source": "currency",
|
|
141
|
+
"target": "currency.refName",
|
|
142
|
+
"transform": "uppercase"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"source": "note",
|
|
146
|
+
"target": "memo",
|
|
147
|
+
"transform": "default",
|
|
148
|
+
"options": {
|
|
149
|
+
"value": "Shopify order"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"filter": "$.record.financial_status == 'paid' || $.record.financial_status == 'partially_refunded'",
|
|
154
|
+
"backfill": {
|
|
155
|
+
"trigger": "userAction",
|
|
156
|
+
"pageSize": 50
|
|
157
|
+
},
|
|
158
|
+
"ongoing": {
|
|
159
|
+
"mode": "webhook"
|
|
160
|
+
},
|
|
161
|
+
"default": "on"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"workflows": [
|
|
165
|
+
{
|
|
166
|
+
"id": "order-lines",
|
|
167
|
+
"label": "Sales order lines and customer",
|
|
168
|
+
"description": "After a sales order is created from a Shopify order, attach the NetSuite customer and turn Shopify line items, shipping and discounts into NetSuite item lines.",
|
|
169
|
+
"purpose": "write",
|
|
170
|
+
"default": "on",
|
|
171
|
+
"trigger": {
|
|
172
|
+
"type": "syncRecord",
|
|
173
|
+
"sync": "orders",
|
|
174
|
+
"on": [
|
|
175
|
+
"created"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"steps": [
|
|
179
|
+
{
|
|
180
|
+
"id": "order",
|
|
181
|
+
"use": "links.find",
|
|
182
|
+
"with": {
|
|
183
|
+
"sync": "orders",
|
|
184
|
+
"from": "shopify",
|
|
185
|
+
"id": "$.record.id"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"id": "customer",
|
|
190
|
+
"use": "links.find",
|
|
191
|
+
"with": {
|
|
192
|
+
"sync": "customers",
|
|
193
|
+
"key": {
|
|
194
|
+
"email": "$.record.email"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"use": "stop",
|
|
200
|
+
"when": "$.steps.order == null || $.steps.customer == null",
|
|
201
|
+
"with": {
|
|
202
|
+
"reason": "Order or customer is not linked yet; the queue will retry"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "lines",
|
|
207
|
+
"use": "code",
|
|
208
|
+
"with": {
|
|
209
|
+
"ref": "@acme/commerce-steps#netsuiteItemLines@1.2.0",
|
|
210
|
+
"with": {
|
|
211
|
+
"lineItems": "$.record.line_items",
|
|
212
|
+
"shipping": "$.record.total_shipping_price_set.shop_money.amount",
|
|
213
|
+
"discountCodes": "$.record.discount_codes",
|
|
214
|
+
"locationId": "$.install.location"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"use": "netsuite.salesOrder.update",
|
|
220
|
+
"with": {
|
|
221
|
+
"id": "$.steps.order.netsuite",
|
|
222
|
+
"record": {
|
|
223
|
+
"entity": {
|
|
224
|
+
"id": "$.steps.customer.netsuite"
|
|
225
|
+
},
|
|
226
|
+
"subsidiary": {
|
|
227
|
+
"id": "$.install.subsidiary"
|
|
228
|
+
},
|
|
229
|
+
"location": {
|
|
230
|
+
"id": "$.install.location"
|
|
231
|
+
},
|
|
232
|
+
"item": {
|
|
233
|
+
"items": "$.steps.lines.items"
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"retry": {
|
|
240
|
+
"max": 5,
|
|
241
|
+
"backoff": "exponential"
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"id": "fulfillment-to-shopify",
|
|
246
|
+
"label": "Write NetSuite fulfillments back to Shopify",
|
|
247
|
+
"description": "When NetSuite ships an item fulfillment, fulfil the matching Shopify fulfillment orders with the tracking number.",
|
|
248
|
+
"purpose": "write",
|
|
249
|
+
"default": "on",
|
|
250
|
+
"settings": {
|
|
251
|
+
"carrier": {
|
|
252
|
+
"type": "enum",
|
|
253
|
+
"label": "Carrier shown to customers",
|
|
254
|
+
"enum": [
|
|
255
|
+
"UPS",
|
|
256
|
+
"USPS",
|
|
257
|
+
"FedEx",
|
|
258
|
+
"DHL Express",
|
|
259
|
+
"Other"
|
|
260
|
+
],
|
|
261
|
+
"default": "UPS"
|
|
262
|
+
},
|
|
263
|
+
"notifyCustomer": {
|
|
264
|
+
"type": "boolean",
|
|
265
|
+
"label": "Send Shopify's shipping confirmation email",
|
|
266
|
+
"default": true
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
"trigger": {
|
|
270
|
+
"type": "webhook",
|
|
271
|
+
"module": "netsuite",
|
|
272
|
+
"topic": "itemFulfillment.created",
|
|
273
|
+
"filter": "$.record.shipStatus == '_shipped'"
|
|
274
|
+
},
|
|
275
|
+
"steps": [
|
|
276
|
+
{
|
|
277
|
+
"id": "order",
|
|
278
|
+
"use": "links.find",
|
|
279
|
+
"with": {
|
|
280
|
+
"sync": "orders",
|
|
281
|
+
"from": "netsuite",
|
|
282
|
+
"id": "$.record.createdFrom.id"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"use": "stop",
|
|
287
|
+
"when": "$.steps.order == null",
|
|
288
|
+
"with": {
|
|
289
|
+
"reason": "Fulfillment is for a sales order that did not come from Shopify"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"id": "fulfillmentOrders",
|
|
294
|
+
"use": "shopify.order.fulfillmentOrders",
|
|
295
|
+
"with": {
|
|
296
|
+
"orderId": "$.steps.order.shopify"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"id": "fulfil",
|
|
301
|
+
"use": "foreach",
|
|
302
|
+
"with": {
|
|
303
|
+
"over": "$.steps.fulfillmentOrders",
|
|
304
|
+
"max": 10
|
|
305
|
+
},
|
|
306
|
+
"do": [
|
|
307
|
+
{
|
|
308
|
+
"use": "shopify.fulfillment.create",
|
|
309
|
+
"when": "$.item.status == 'open' || $.item.status == 'in_progress'",
|
|
310
|
+
"with": {
|
|
311
|
+
"fulfillmentOrderId": "$.item.id",
|
|
312
|
+
"trackingInfo": {
|
|
313
|
+
"number": "$.record.package.packages[0].packageTrackingNumber",
|
|
314
|
+
"company": "$.settings.carrier"
|
|
315
|
+
},
|
|
316
|
+
"notifyCustomer": "$.settings.notifyCustomer"
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"id": "low-stock-alert",
|
|
325
|
+
"label": "Low-stock alert in Slack",
|
|
326
|
+
"purpose": "notify",
|
|
327
|
+
"default": "off",
|
|
328
|
+
"settings": {
|
|
329
|
+
"threshold": {
|
|
330
|
+
"type": "number",
|
|
331
|
+
"label": "Alert when available stock falls to",
|
|
332
|
+
"default": 5
|
|
333
|
+
},
|
|
334
|
+
"channel": {
|
|
335
|
+
"type": "option",
|
|
336
|
+
"options": "slack.channel",
|
|
337
|
+
"label": "Post alerts to",
|
|
338
|
+
"required": true
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
"trigger": {
|
|
342
|
+
"type": "webhook",
|
|
343
|
+
"module": "shopify",
|
|
344
|
+
"topic": "inventory.updated",
|
|
345
|
+
"filter": "$.record.available <= $.settings.threshold"
|
|
346
|
+
},
|
|
347
|
+
"steps": [
|
|
348
|
+
{
|
|
349
|
+
"id": "variant",
|
|
350
|
+
"use": "shopify.variant.byInventoryItem",
|
|
351
|
+
"with": {
|
|
352
|
+
"inventoryItemId": "$.record.inventory_item_id"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"id": "text",
|
|
357
|
+
"use": "template",
|
|
358
|
+
"with": {
|
|
359
|
+
"id": "low-stock"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"use": "slack.message.post",
|
|
364
|
+
"with": {
|
|
365
|
+
"channel": "$.settings.channel",
|
|
366
|
+
"text": "$.steps.text",
|
|
367
|
+
"unfurl_links": false
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"id": "refund-credit-memo",
|
|
374
|
+
"label": "Refunds become credit memos",
|
|
375
|
+
"description": "A Shopify refund creates a NetSuite credit memo against the original sales order, for the refunded lines only.",
|
|
376
|
+
"purpose": "write",
|
|
377
|
+
"default": "on",
|
|
378
|
+
"trigger": {
|
|
379
|
+
"type": "webhook",
|
|
380
|
+
"module": "shopify",
|
|
381
|
+
"topic": "refund.created"
|
|
382
|
+
},
|
|
383
|
+
"steps": [
|
|
384
|
+
{
|
|
385
|
+
"id": "order",
|
|
386
|
+
"use": "links.find",
|
|
387
|
+
"with": {
|
|
388
|
+
"sync": "orders",
|
|
389
|
+
"from": "shopify",
|
|
390
|
+
"id": "$.record.order_id"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"use": "stop",
|
|
395
|
+
"when": "$.steps.order == null",
|
|
396
|
+
"with": {
|
|
397
|
+
"reason": "Refunded order was never synced to NetSuite"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"id": "salesOrder",
|
|
402
|
+
"use": "netsuite.salesOrder.get",
|
|
403
|
+
"with": {
|
|
404
|
+
"id": "$.steps.order.netsuite"
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"id": "lines",
|
|
409
|
+
"use": "code",
|
|
410
|
+
"with": {
|
|
411
|
+
"ref": "@acme/commerce-steps#netsuiteRefundLines@1.2.0",
|
|
412
|
+
"with": {
|
|
413
|
+
"refundLineItems": "$.record.refund_line_items",
|
|
414
|
+
"transactions": "$.record.transactions",
|
|
415
|
+
"salesOrderLines": "$.steps.salesOrder.item.items"
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"id": "memo",
|
|
421
|
+
"use": "template",
|
|
422
|
+
"with": {
|
|
423
|
+
"id": "credit-memo"
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"use": "netsuite.creditMemo.create",
|
|
428
|
+
"with": {
|
|
429
|
+
"record": {
|
|
430
|
+
"externalId": "shopify-refund-{{record.id}}",
|
|
431
|
+
"entity": {
|
|
432
|
+
"id": "$.steps.salesOrder.entity.id"
|
|
433
|
+
},
|
|
434
|
+
"createdFrom": {
|
|
435
|
+
"id": "$.steps.order.netsuite"
|
|
436
|
+
},
|
|
437
|
+
"tranDate": "$.record.created_at",
|
|
438
|
+
"memo": "$.steps.memo",
|
|
439
|
+
"item": {
|
|
440
|
+
"items": "$.steps.lines.items"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
]
|
|
446
|
+
}
|
|
447
|
+
],
|
|
448
|
+
"queries": [
|
|
449
|
+
{
|
|
450
|
+
"id": "netsuite-order",
|
|
451
|
+
"description": "The NetSuite sales order behind this Shopify order.",
|
|
452
|
+
"steps": [
|
|
453
|
+
{
|
|
454
|
+
"id": "order",
|
|
455
|
+
"use": "links.find",
|
|
456
|
+
"with": {
|
|
457
|
+
"sync": "orders",
|
|
458
|
+
"from": "shopify",
|
|
459
|
+
"id": "$.record.id"
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"use": "stop",
|
|
464
|
+
"when": "$.steps.order == null",
|
|
465
|
+
"with": {
|
|
466
|
+
"reason": "Not synced"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"id": "salesOrder",
|
|
471
|
+
"use": "netsuite.salesOrder.get",
|
|
472
|
+
"with": {
|
|
473
|
+
"id": "$.steps.order.netsuite"
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
"returns": {
|
|
478
|
+
"salesOrder": "$.steps.salesOrder"
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
"ui": [
|
|
483
|
+
{
|
|
484
|
+
"id": "netsuite-status",
|
|
485
|
+
"label": "NetSuite",
|
|
486
|
+
"host": "shopify",
|
|
487
|
+
"placement": "admin.order-details.block",
|
|
488
|
+
"objects": [
|
|
489
|
+
"order"
|
|
490
|
+
],
|
|
491
|
+
"data": {
|
|
492
|
+
"query": "netsuite-order"
|
|
493
|
+
},
|
|
494
|
+
"view": {
|
|
495
|
+
"component": "Stack",
|
|
496
|
+
"children": [
|
|
497
|
+
{
|
|
498
|
+
"component": "Heading",
|
|
499
|
+
"props": {
|
|
500
|
+
"text": "NetSuite sales order"
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"component": "Empty",
|
|
505
|
+
"when": "!($.data.salesOrder exists)",
|
|
506
|
+
"props": {
|
|
507
|
+
"text": "This order has not reached NetSuite yet. Only paid orders are synced."
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"component": "KeyValue",
|
|
512
|
+
"when": "$.data.salesOrder exists",
|
|
513
|
+
"props": {
|
|
514
|
+
"items": [
|
|
515
|
+
{
|
|
516
|
+
"label": "Document",
|
|
517
|
+
"value": "{{data.salesOrder.tranId}}"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"label": "Status",
|
|
521
|
+
"value": "{{data.salesOrder.orderStatus}}"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"label": "Total",
|
|
525
|
+
"value": "{{data.salesOrder.total}} {{data.salesOrder.currency.refName}}"
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
],
|
|
534
|
+
"templates": {
|
|
535
|
+
"low-stock": ":warning: Low stock: *{{steps.variant.product_title}}* ({{steps.variant.sku}}) has {{record.available}} left at location {{record.location_id}}.",
|
|
536
|
+
"credit-memo": "Shopify refund {{record.id}} on order {{steps.salesOrder.otherRefNum}}. {{record.note | default: 'No reason given.'}}"
|
|
537
|
+
},
|
|
538
|
+
"lifecycle": {
|
|
539
|
+
"onInstall": [
|
|
540
|
+
{
|
|
541
|
+
"use": "shopify.webhook.create",
|
|
542
|
+
"with": {
|
|
543
|
+
"topic": "orders/create",
|
|
544
|
+
"address": "$.install.webhookUrls.shopify",
|
|
545
|
+
"format": "json"
|
|
546
|
+
},
|
|
547
|
+
"id": "hook-orders-create"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"use": "shopify.webhook.create",
|
|
551
|
+
"with": {
|
|
552
|
+
"topic": "orders/paid",
|
|
553
|
+
"address": "$.install.webhookUrls.shopify",
|
|
554
|
+
"format": "json"
|
|
555
|
+
},
|
|
556
|
+
"id": "hook-orders-paid"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"use": "shopify.webhook.create",
|
|
560
|
+
"with": {
|
|
561
|
+
"topic": "customers/create",
|
|
562
|
+
"address": "$.install.webhookUrls.shopify",
|
|
563
|
+
"format": "json"
|
|
564
|
+
},
|
|
565
|
+
"id": "hook-customers-create"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"use": "shopify.webhook.create",
|
|
569
|
+
"with": {
|
|
570
|
+
"topic": "customers/update",
|
|
571
|
+
"address": "$.install.webhookUrls.shopify",
|
|
572
|
+
"format": "json"
|
|
573
|
+
},
|
|
574
|
+
"id": "hook-customers-update"
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"use": "shopify.webhook.create",
|
|
578
|
+
"with": {
|
|
579
|
+
"topic": "refunds/create",
|
|
580
|
+
"address": "$.install.webhookUrls.shopify",
|
|
581
|
+
"format": "json"
|
|
582
|
+
},
|
|
583
|
+
"id": "hook-refunds-create"
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
"use": "shopify.webhook.create",
|
|
587
|
+
"with": {
|
|
588
|
+
"topic": "inventory_levels/update",
|
|
589
|
+
"address": "$.install.webhookUrls.shopify",
|
|
590
|
+
"format": "json"
|
|
591
|
+
},
|
|
592
|
+
"id": "hook-inventory-levels-update"
|
|
593
|
+
}
|
|
594
|
+
],
|
|
595
|
+
"onUninstall": [
|
|
596
|
+
{
|
|
597
|
+
"id": "unhook",
|
|
598
|
+
"use": "foreach",
|
|
599
|
+
"with": {
|
|
600
|
+
"over": [
|
|
601
|
+
"$.install.runtime.installed.hook-orders-create.id",
|
|
602
|
+
"$.install.runtime.installed.hook-orders-paid.id",
|
|
603
|
+
"$.install.runtime.installed.hook-customers-create.id",
|
|
604
|
+
"$.install.runtime.installed.hook-customers-update.id",
|
|
605
|
+
"$.install.runtime.installed.hook-refunds-create.id",
|
|
606
|
+
"$.install.runtime.installed.hook-inventory-levels-update.id"
|
|
607
|
+
],
|
|
608
|
+
"max": 20
|
|
609
|
+
},
|
|
610
|
+
"do": [
|
|
611
|
+
{
|
|
612
|
+
"use": "shopify.webhook.delete",
|
|
613
|
+
"with": {
|
|
614
|
+
"id": "$.item"
|
|
615
|
+
},
|
|
616
|
+
"onError": "continue"
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
}
|