Skip to content

Commit

Permalink
fix(transformer): fix demo-shop catalog transform.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Jan 24, 2024
1 parent 0f6bf78 commit b749614
Show file tree
Hide file tree
Showing 19 changed files with 258 additions and 359 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@ jobs:
- name: Install Dependencies
run: npm ci

- name: Import system master data
run: |
API_KEY=$(docker logs restorecommerce_facade_srv 2>/dev/null | grep API | awk '{print $7}')
node import.js import -t $API_KEY -d system -j master
- name: Extract Bootstrap API-KEY
run: npm run env:token

- name: Import system identity data
run: |
API_KEY=$(docker logs restorecommerce_facade_srv 2>/dev/null | grep API | awk '{print $7}')
node import.js import -t $API_KEY -d system -j identity
- name: Import extra data
run: |
API_KEY=$(docker logs restorecommerce_facade_srv 2>/dev/null | grep API | awk '{print $7}')
node import.js import -t $API_KEY -d system -j extra
- name: Import all
run: npm run import
24 changes: 15 additions & 9 deletions datasets/demo-shop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ to import the data locally or into the production environment.

### Current supported jobs are

- master (imports resources `organizations`, `addresses`, `contact_points`, `shops`, `customers`)
- master (imports `organizations`, `addresses`, `contact_points`, `shops`, `customers`)
- identity (imports `users`)
- catalog (imports resources `price_group`, `manufacturer`, `product_category`, `product_prototype`, `product`)
- catalog (imports `price_group`, `manufacturer`, `product_category`, `product_prototype`, `product`)

> NOTE: Resources must be imported in a specific order!
> NOTE: Resources should be imported in a specific order!
> Master > Identity > Catalog.
>
> For the case when importing resources returns "Access denied", one way to fix
Expand All @@ -41,15 +41,15 @@ to import the data locally or into the production environment.

2. Either export the API-KEY, paste it to an `.env` file or paste as command argument.

2. Generate catalog datasets using [`transform.js script`](./generator/catalog/transform.js):
3. Generate catalog datasets using [`transform.js script`](./generator/catalog/transform.js):

- `node ./transform.js`

3. Import datasets using [`import.js script`](./import.js):
4. Import datasets using [`import.js script`](./import.js):

- `node ./import.js import -t <access_token> -d demo-shop -j <job>`

4. Examples:
5. Examples:

- `node ./import.js import -t <access_token> -d demo-shop -j master`
- `node ./import.js import -t <access_token> -d demo-shop -j identity`
Expand All @@ -60,10 +60,16 @@ to import the data locally or into the production environment.
All flags are optional, and they can be listed by typing `node ./import.js -h`.
The API key can be obtained from the [`facade-srv`](https://github.com/restorecommerce/facade-srv/blob/master/cfg/config.json#L21) configuration.
The API key is generated during system startup from the `facade-srv` (Check the log message of facade-srv `Bootstrap API Key is`).
In case `facade-srv` is a local container use the following command to extract the `Bootstrap API-KEY`:

```sh
npm run env:token
```

By default, the GraphQL importer uses the configuration file `config.json` to read data regarding endpoints for retrieving the API key
and executing mutations/ queries.


## Object Importer

To import the files, following settings needs to be configured in [config.json](cfg/config.json):
Expand All @@ -75,10 +81,10 @@ Prerequisite: object importer should be build using `npm run build` command befo

```sh
# Run import in production-mode:
npm run import-objects -- --apiKey=<access_token> -- --NODE_ENV=local
npm run import:demoshop:objects -- --apiKey=<access_token> -- --NODE_ENV=local

# Run import in production-mode:
npm run import-objects -- --apiKey=<access_token> -- --NODE_ENV=production
npm run import:demoshop:objects -- --apiKey=<access_token> -- --NODE_ENV=production
# or:
npm run import-objects -- --apiKey=<access_token> # default is development
npm run import:demoshop:objects -- --apiKey=<access_token> # default is development
```
8 changes: 4 additions & 4 deletions datasets/demo-shop/data/seed-data/addresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
street: Ossietzkystraße
buildingNumber: '4'
region: Stuttgart
countryId: restorecommecre-demo-country-germany
countryId: germany
altitude: 0
addressAddition:
field1: ""
Expand All @@ -28,7 +28,7 @@
street: Erste Teststraße
buildingNumber: '1'
region: Testregion
countryId: restorecommecre-demo-country-germany
countryId: germany
altitude: 0
addressAddition:
field1: ""
Expand All @@ -51,7 +51,7 @@
street: Zweite Teststraße
buildingNumber: '1'
region: Beispielregion
countryId: restorecommecre-demo-country-germany
countryId: germany
altitude: 0
addressAddition:
field1: ""
Expand All @@ -74,7 +74,7 @@
street: Zweite Teststraße
buildingNumber: '1'
region: Beispielregion
countryId: restorecommecre-demo-country-germany
countryId: germany
altitude: 0
addressAddition:
field1: ""
Expand Down
14 changes: 7 additions & 7 deletions datasets/demo-shop/data/seed-data/customers.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: restorecommecre-demo-customer-000
commercial:
organization_id: restorecommecre-demo-customer-000-organization
organizationId: restorecommecre-demo-customer-000-organization
meta:
modifiedBy: ""
owners:
Expand All @@ -12,8 +12,8 @@
value: restorecommecre-demo-customer-000-organization
---
id: restorecommecre-demo-customer-001
public_sector:
organization_id: restorecommecre-demo-customer-organization-001
publicSector:
organizationId: restorecommecre-demo-customer-organization-001
meta:
modifiedBy: ""
owners:
Expand All @@ -25,8 +25,8 @@
---
id: restorecommecre-demo-customer-002
private:
user_id: restorecommecre-demo-customer-002-user
contact_point_ids: [
userId: restorecommecre-demo-customer-002-user
contactPointIds: [
restorecommecre-demo-customer-002-contact-point
]
meta:
Expand All @@ -40,8 +40,8 @@
---
id: restorecommecre-demo-customer-unauthenticated
private:
user_id: unauthenticated_user
contact_point_ids: []
userId: unauthenticated_user
contactPointIds: []
meta:
modifiedBy: ""
owners:
Expand Down
4 changes: 1 addition & 3 deletions datasets/demo-shop/data/seed-data/organizations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
id: restorecommecre-demo-shop-000-organization
name: Restorecommerce Demo Shop 000 Organization
contactPointIds:
- restorecommecre-demo-shop-000-contact-point-billing
- restorecommecre-demo-shop-000-contact-point-shipping
- restorecommecre-demo-shop-000-contact-point-legal
- restorecommecre-demo-shop-000-contact-point
website: https://about.restorecommerce.io/
email: [email protected]
vatId: DE000000000
Expand Down
1 change: 0 additions & 1 deletion datasets/demo-shop/generator/catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"dependencies": {
"csv-parser": "^2.3.1",
"js-yaml": "^3.14.0",
"lodash": "^4.17.21",
"object-hash": "^2.0.0",
"uuid": "^3.3.3"
},
Expand Down
Loading

0 comments on commit b749614

Please sign in to comment.