@reactionary/examples-node 0.6.1 → 0.6.3

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/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@reactionary/examples-node",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.6.1",
8
- "@reactionary/provider-commercetools": "0.6.1",
9
- "@reactionary/provider-algolia": "0.6.1",
10
- "@reactionary/provider-medusa": "0.6.1",
11
- "@reactionary/provider-meilisearch": "0.6.1",
12
- "@reactionary/provider-fake": "0.6.1"
7
+ "@reactionary/core": "0.6.3",
8
+ "@reactionary/commercetools": "0.6.3",
9
+ "@reactionary/algolia": "0.6.3",
10
+ "@reactionary/medusa": "0.6.3",
11
+ "@reactionary/meilisearch": "0.6.3",
12
+ "@reactionary/fake": "0.6.3"
13
13
  },
14
14
  "type": "module"
15
15
  }
@@ -7,9 +7,10 @@ import {
7
7
  ProductSchema
8
8
  } from '@reactionary/core';
9
9
  import {
10
+ FakeProductFactory,
10
11
  FakeProductProvider,
11
12
  withFakeCapabilities,
12
- } from '@reactionary/provider-fake';
13
+ } from '@reactionary/fake';
13
14
  import { createInitialRequestContext } from '@reactionary/core'
14
15
  import * as z from 'zod';
15
16
  import { describe, expect, it } from 'vitest';
@@ -23,9 +24,9 @@ describe('basic node provider extension (models)', () => {
23
24
  type ExtendedProduct = z.infer<typeof ExtendedProductModel>;
24
25
 
25
26
  class ExtendedProductProvider extends FakeProductProvider {
26
- protected override parseSingle(body: string): ExtendedProduct {
27
+ protected override composeSingle(body: string): ExtendedProduct {
27
28
  const result = {
28
- ...super.parseSingle(body),
29
+ ...super.composeSingle(body),
29
30
  gtin: 'gtin-1234'
30
31
  } satisfies ExtendedProduct;
31
32
 
@@ -44,7 +45,8 @@ describe('basic node provider extension (models)', () => {
44
45
  search: 1
45
46
  } },
46
47
  cache,
47
- context
48
+ context,
49
+ new FakeProductFactory(ExtendedProductModel)
48
50
  ),
49
51
  };
50
52
 
@@ -66,7 +68,11 @@ describe('basic node provider extension (models)', () => {
66
68
  search: 1
67
69
  }
68
70
  },
69
- { productSearch: true, product: false, identity: false }
71
+ {
72
+ productSearch: { enabled: true },
73
+ product: { enabled: false },
74
+ identity: { enabled: false },
75
+ }
70
76
  )
71
77
  )
72
78
  .withCapability(withExtendedCapabilities())
@@ -9,9 +9,10 @@ import {
9
9
  ProductSchema
10
10
  } from '@reactionary/core';
11
11
  import {
12
+ FakeProductFactory,
12
13
  FakeProductProvider,
13
14
  withFakeCapabilities,
14
- } from '@reactionary/provider-fake';
15
+ } from '@reactionary/fake';
15
16
  import * as z from 'zod';
16
17
  import { describe, expect, it } from 'vitest';
17
18
 
@@ -60,7 +61,8 @@ describe('basic node provider extension (models)', () => {
60
61
  search: 1
61
62
  }},
62
63
  cache,
63
- context
64
+ context,
65
+ new FakeProductFactory(ProductSchema)
64
66
  ),
65
67
  };
66
68
 
@@ -83,7 +85,11 @@ describe('basic node provider extension (models)', () => {
83
85
  search: 1
84
86
  }
85
87
  },
86
- { productSearch: true, product: false, identity: false }
88
+ {
89
+ productSearch: { enabled: true },
90
+ product: { enabled: false },
91
+ identity: { enabled: false },
92
+ }
87
93
  )
88
94
  )
89
95
  .withCapability(withExtendedCapabilities())
@@ -6,7 +6,7 @@ import {
6
6
  type Client,
7
7
  type RequestContext,
8
8
  } from '@reactionary/core';
9
- import { withFakeCapabilities } from '@reactionary/provider-fake';
9
+ import { withFakeCapabilities } from '@reactionary/fake';
10
10
  import { assert, beforeAll, beforeEach, describe, expect, it } from 'vitest';
11
11
 
12
12
  describe('basic node setup', () => {
@@ -29,7 +29,11 @@ describe('basic node setup', () => {
29
29
  search: 1,
30
30
  },
31
31
  },
32
- { productSearch: true, product: true, identity: false }
32
+ {
33
+ productSearch: { enabled: true },
34
+ product: { enabled: true },
35
+ identity: { enabled: false },
36
+ }
33
37
  )
34
38
  )
35
39
  .withCache(new NoOpCache())
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { ClientBuilder, createInitialRequestContext, NoOpCache } from '@reactionary/core';
3
- import { FakeProductProvider, withFakeCapabilities } from '@reactionary/provider-fake';
4
- import { CommercetoolsCartProvider, withCommercetoolsCapabilities } from '@reactionary/provider-commercetools';
5
- import { AlgoliaProductSearchProvider, withAlgoliaCapabilities } from '@reactionary/provider-algolia';
3
+ import { FakeProductProvider, withFakeCapabilities } from '@reactionary/fake';
4
+ import { CommercetoolsCartProvider, withCommercetoolsCapabilities } from '@reactionary/commercetools';
5
+ import { AlgoliaProductSearchProvider, withAlgoliaCapabilities } from "@reactionary/algolia";
6
6
 
7
7
  describe('client creation', () => {
8
8
  it('should be able to mix providers and get a valid, typed client', async () => {
@@ -21,7 +21,7 @@ describe('client creation', () => {
21
21
  search: 1,
22
22
  },
23
23
  },
24
- { product: true }
24
+ { product: { enabled: true } }
25
25
  )
26
26
  )
27
27
  .withCapability(
@@ -34,14 +34,14 @@ describe('client creation', () => {
34
34
  projectKey: '',
35
35
  scopes: [],
36
36
  facetFieldsForSearch: []
37
- }, { cart: true })
37
+ }, { cart: { enabled: true } })
38
38
  )
39
39
  .withCapability(
40
40
  withAlgoliaCapabilities({
41
41
  apiKey: '',
42
42
  appId: '',
43
43
  indexName: ''
44
- }, { productSearch: true })
44
+ }, { productSearch: { enabled: true } })
45
45
  )
46
46
  .withCache(new NoOpCache())
47
47
  .build();
package/src/utils.ts CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  ClientBuilder,
4
4
  NoOpCache,
5
5
  } from '@reactionary/core';
6
- import type { CommercetoolsConfiguration } from '@reactionary/provider-commercetools';
7
- import { withCommercetoolsCapabilities } from '@reactionary/provider-commercetools';
8
- import { withAlgoliaCapabilities } from '@reactionary/provider-algolia';
9
- import { withMedusaCapabilities } from '@reactionary/provider-medusa';
10
- import { withMeilisearchCapabilities } from '@reactionary/provider-meilisearch';
11
- import { withFakeCapabilities } from '@reactionary/provider-fake';
12
- import type { FakeConfiguration } from '@reactionary/provider-fake';
6
+ import type { CommercetoolsConfiguration } from '@reactionary/commercetools';
7
+ import { withCommercetoolsCapabilities } from '@reactionary/commercetools';
8
+ import { withAlgoliaCapabilities } from "@reactionary/algolia";
9
+ import { withMedusaCapabilities } from '@reactionary/medusa';
10
+ import { withMeilisearchCapabilities } from '@reactionary/meilisearch';
11
+ import { withFakeCapabilities } from '@reactionary/fake';
12
+ import type { FakeConfiguration } from '@reactionary/fake';
13
13
 
14
14
  export function getAlgoliaTestConfiguration() {
15
15
  return {
@@ -99,20 +99,20 @@ export function createClient(provider: PrimaryProvider) {
99
99
  if (provider === PrimaryProvider.MEDUSA) {
100
100
  builder = builder.withCapability(
101
101
  withMedusaCapabilities( getMedusaTestConfiguration(), {
102
- cart: true,
103
- product: true,
104
- category: true,
105
- checkout: true,
106
- identity: true,
107
- inventory: true,
108
- order: true,
109
- price: true,
110
- productSearch: true,
111
- productRecommendations: true,
112
- productAssociations: true,
113
- orderSearch: true,
114
- store: true,
115
- profile: true,
102
+ cart: { enabled: true },
103
+ product: { enabled: true },
104
+ category: { enabled: true },
105
+ checkout: { enabled: true },
106
+ identity: { enabled: true },
107
+ inventory: { enabled: true },
108
+ order: { enabled: true },
109
+ price: { enabled: true },
110
+ productSearch: { enabled: true },
111
+ productRecommendations: { enabled: true },
112
+ productAssociations: { enabled: true },
113
+ orderSearch: { enabled: true },
114
+ store: { enabled: true },
115
+ profile: { enabled: true },
116
116
  })
117
117
  );
118
118
  }
@@ -120,11 +120,11 @@ export function createClient(provider: PrimaryProvider) {
120
120
  if (provider === PrimaryProvider.FAKE) {
121
121
  builder = builder.withCapability(
122
122
  withFakeCapabilities( getFakeConfiguration() , {
123
- price: true,
124
- inventory: true,
125
- product: true,
126
- productReviews: true,
127
- productAssociations: true,
123
+ price: { enabled: true },
124
+ inventory: { enabled: true },
125
+ product: { enabled: true },
126
+ productReviews: { enabled: true },
127
+ productAssociations: { enabled: true },
128
128
  }
129
129
  ))
130
130
  }
@@ -132,21 +132,21 @@ export function createClient(provider: PrimaryProvider) {
132
132
  if (provider === PrimaryProvider.COMMERCETOOLS) {
133
133
  builder = builder.withCapability(
134
134
  withCommercetoolsCapabilities(getCommercetoolsTestConfiguration(), {
135
- cart: true,
136
- product: true,
137
- category: true,
138
- checkout: true,
139
- identity: true,
140
- inventory: true,
141
- order: true,
142
- price: true,
143
- productSearch: true,
144
- productAssociations: true,
145
- productReviews: true,
146
- productList: true,
147
- orderSearch: true,
148
- store: true,
149
- profile: true,
135
+ cart: { enabled: true },
136
+ product: { enabled: true },
137
+ category: { enabled: true },
138
+ checkout: { enabled: true },
139
+ identity: { enabled: true },
140
+ inventory: { enabled: true },
141
+ order: { enabled: true },
142
+ price: { enabled: true },
143
+ productSearch: { enabled: true },
144
+ productAssociations: { enabled: true },
145
+ productReviews: { enabled: true },
146
+ productList: { enabled: true },
147
+ orderSearch: { enabled: true },
148
+ store: { enabled: true },
149
+ profile: { enabled: true },
150
150
  })
151
151
  );
152
152
  }
@@ -155,8 +155,8 @@ export function createClient(provider: PrimaryProvider) {
155
155
  if (provider === PrimaryProvider.ALGOLIA) {
156
156
  builder = builder.withCapability(
157
157
  withAlgoliaCapabilities(getAlgoliaTestConfiguration(), {
158
- productSearch: true,
159
- productRecommendations: true,
158
+ productSearch: { enabled: true },
159
+ productRecommendations: { enabled: true },
160
160
  })
161
161
  );
162
162
  }
@@ -164,15 +164,15 @@ export function createClient(provider: PrimaryProvider) {
164
164
  if (provider === PrimaryProvider.MEILISEARCH) {
165
165
  builder = builder.withCapability(
166
166
  withMeilisearchCapabilities(getMeilisearchTestConfiguration(), {
167
- productSearch: true,
168
- orderSearch: true,
169
- productRecommendations: true,
167
+ productSearch: { enabled: true },
168
+ orderSearch: { enabled: true },
169
+ productRecommendations: { enabled: true },
170
170
  }),
171
171
  );
172
172
  builder = builder.withCapability(
173
173
  withMedusaCapabilities(getMedusaTestConfiguration(), {
174
- cart: true,
175
- identity: true,
174
+ cart: { enabled: true },
175
+ identity: { enabled: true },
176
176
  })
177
177
  );
178
178
  }
package/tsconfig.lib.json CHANGED
@@ -5,5 +5,6 @@
5
5
  "declaration": true,
6
6
  "types": ["node"]
7
7
  },
8
- "include": ["src/**/*.ts"]
8
+ "include": ["src/**/*.ts"],
9
+ "exclude": ["src/**/*.spec.ts", "src/utils.ts"]
9
10
  }