@vtex/api 6.45.2 → 6.45.6

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.
@@ -110,6 +110,9 @@
110
110
  "email": {
111
111
  "type": "string"
112
112
  },
113
+ "phone": {
114
+ "type": "string"
115
+ },
113
116
  "url": {
114
117
  "type": "string"
115
118
  }
@@ -30,7 +30,7 @@ export declare class Segment extends JanusClient {
30
30
  getSegmentByToken: (token: string | null, tracingConfig?: RequestTracingConfig | undefined) => Promise<SegmentData>;
31
31
  getOrCreateSegment: (query?: Record<string, string> | undefined, token?: string | undefined, tracingConfig?: RequestTracingConfig | undefined) => Promise<{
32
32
  segmentData: SegmentData;
33
- segmentToken: string;
33
+ segmentToken: string | null;
34
34
  }>;
35
35
  private rawSegment;
36
36
  }
@@ -25,7 +25,7 @@ const filterAndSortQuery = (query) => {
25
25
  };
26
26
  const routes = {
27
27
  base: '/api/segments',
28
- segments: (token) => token ? `${routes.base}/${token}` : routes.base,
28
+ segments: (token) => (token ? `${routes.base}/${token}` : routes.base),
29
29
  };
30
30
  class Segment extends JanusClient_1.JanusClient {
31
31
  constructor() {
@@ -43,19 +43,17 @@ class Segment extends JanusClient_1.JanusClient {
43
43
  */
44
44
  this.getSegmentByToken = (token, tracingConfig) => this.rawSegment(token, undefined, tracingConfig).then(ramda_1.prop('data'));
45
45
  this.getOrCreateSegment = async (query, token, tracingConfig) => {
46
- const { data: segmentData, headers: { 'set-cookie': [setCookies], }, } = await this.rawSegment(token, query, tracingConfig);
47
- const parsedCookie = cookie_1.default.parse(setCookies);
48
- const segmentToken = ramda_1.prop(SEGMENT_COOKIE, parsedCookie);
46
+ const { data: segmentData, headers } = await this.rawSegment(token, query, tracingConfig);
49
47
  return {
50
48
  segmentData,
51
- segmentToken,
49
+ segmentToken: extractSegmentCookie(headers),
52
50
  };
53
51
  };
54
52
  this.rawSegment = (token, query, tracingConfig) => {
55
53
  const { product, workspace } = this.context;
56
54
  const filteredQuery = filterAndSortQuery(query);
57
55
  const metric = token ? 'segment-get-token' : 'segment-get-new';
58
- return this.http.getRaw(routes.segments(token), ({
56
+ return this.http.getRaw(routes.segments(token), {
59
57
  forceMaxAge: SEGMENT_MAX_AGE_S,
60
58
  headers: {
61
59
  'Content-Type': 'application/json',
@@ -72,8 +70,19 @@ class Segment extends JanusClient_1.JanusClient {
72
70
  requestSpanNameSuffix: metric,
73
71
  ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing,
74
72
  },
75
- }));
73
+ });
76
74
  };
77
75
  }
78
76
  }
79
77
  exports.Segment = Segment;
78
+ function extractSegmentCookie(headers) {
79
+ var _a;
80
+ for (const setCookie of (_a = headers['set-cookie']) !== null && _a !== void 0 ? _a : []) {
81
+ const parsedCookie = cookie_1.default.parse(setCookie);
82
+ const segmentCookie = parsedCookie[SEGMENT_COOKIE];
83
+ if (segmentCookie != null) {
84
+ return segmentCookie;
85
+ }
86
+ }
87
+ return null;
88
+ }
@@ -21,7 +21,7 @@ class Session extends JanusClient_1.JanusClient {
21
21
  const { data: sessionData, headers } = await this.http.getRaw(routes.base, {
22
22
  headers: {
23
23
  'Content-Type': 'application/json',
24
- 'Cookie': `vtex_session=${token};`,
24
+ Cookie: `vtex_session=${token};`,
25
25
  },
26
26
  metric,
27
27
  params: {
@@ -46,7 +46,7 @@ class Session extends JanusClient_1.JanusClient {
46
46
  const config = {
47
47
  headers: {
48
48
  'Content-Type': 'application/json',
49
- 'Cookie': `vtex_session=${token};`,
49
+ Cookie: `vtex_session=${token};`,
50
50
  },
51
51
  metric,
52
52
  params: {
@@ -6,7 +6,6 @@ const index_1 = require("../schema/index");
6
6
  exports.updateSchema = (graphql, executableSchema) => async function updateRunnableSchema(ctx, next) {
7
7
  const { clients: { apps }, vtex: { logger }, app, } = ctx;
8
8
  if (!ctx.headers[constants_1.PROVIDER_HEADER]) {
9
- logger.warn({ message: 'Missing x-vtex-provider header' });
10
9
  await next();
11
10
  return;
12
11
  }
@@ -120,11 +120,11 @@ class MineWinsConflictsResolver {
120
120
  });
121
121
  }
122
122
  shouldAddToMine(item, base, mine) {
123
- if (this.comparableKeys && Object.keys(item).some(key => this.comparableKeys.includes(key))) {
124
- return (!mine.some(mineItem => this.comparableKeys.some(key => ramda_1.eqProps(key, item, mineItem))) &&
125
- !base.some(baseItem => this.comparableKeys.some(key => ramda_1.eqProps(key, item, baseItem))));
123
+ if (this.comparableKeys && Object.keys(item).some((key) => this.comparableKeys.includes(key))) {
124
+ return (!mine.some((mineItem) => this.comparableKeys.some((key) => ramda_1.eqProps(key, item, mineItem))) &&
125
+ !base.some((baseItem) => ramda_1.equals(baseItem, item)));
126
126
  }
127
- return !mine.some(mineItem => ramda_1.equals(mineItem, item)) && !base.some(baseItem => ramda_1.equals(baseItem, item));
127
+ return !mine.some((mineItem) => ramda_1.equals(mineItem, item)) && !base.some((baseItem) => ramda_1.equals(baseItem, item));
128
128
  }
129
129
  }
130
130
  exports.MineWinsConflictsResolver = MineWinsConflictsResolver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.45.2",
3
+ "version": "6.45.6",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",