@shopify/cli-kit 3.46.3 → 3.47.0-pre.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/assets/cli-ruby/lib/graphql/extension_create.graphql +1 -0
- package/assets/cli-ruby/lib/graphql/extension_update_draft.graphql +1 -0
- package/assets/cli-ruby/lib/graphql/get_extension_registrations.graphql +1 -0
- package/dist/private/node/api.d.ts +1 -1
- package/dist/private/node/api.js +1 -1
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/session/exchange.d.ts +1 -0
- package/dist/private/node/session/exchange.js +3 -1
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/identity.js +12 -0
- package/dist/private/node/session/identity.js.map +1 -1
- package/dist/private/node/session/scopes.js +5 -1
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session.d.ts +7 -0
- package/dist/private/node/session.js +8 -1
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/ui/components/Alert.js +7 -12
- package/dist/private/node/ui/components/Alert.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +7 -10
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/Banner.js +9 -11
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +63 -29
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +5 -6
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +8 -11
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/List.js +2 -4
- package/dist/private/node/ui/components/List.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +32 -0
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js +2 -3
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.d.ts +9 -7
- package/dist/private/node/ui/components/SelectInput.js +41 -61
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +205 -62
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +4 -16
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +29 -0
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.d.ts +2 -2
- package/dist/private/node/ui/components/TextAnimation.js +4 -3
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
- package/dist/private/node/ui/hooks/use-select-state.d.ts +85 -0
- package/dist/private/node/ui/hooks/use-select-state.js +180 -0
- package/dist/private/node/ui/hooks/use-select-state.js.map +1 -0
- package/dist/private/node/ui.js +2 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/business-platform.d.ts +10 -0
- package/dist/public/node/api/business-platform.js +25 -0
- package/dist/public/node/api/business-platform.js.map +1 -0
- package/dist/public/node/context/fqdn.d.ts +6 -0
- package/dist/public/node/context/fqdn.js +17 -0
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/metadata.d.ts +1 -1
- package/dist/public/node/metadata.js.map +1 -1
- package/dist/public/node/monorail.d.ts +2 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/session.d.ts +7 -0
- package/dist/public/node/session.js +16 -0
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/ui.d.ts +2 -2
- package/dist/public/node/ui.js +2 -2
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { useReducer, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
export default class OptionMap extends Map {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
const items = [];
|
|
6
|
+
let firstItem;
|
|
7
|
+
let previous;
|
|
8
|
+
let index = 0;
|
|
9
|
+
for (const option of options) {
|
|
10
|
+
const item = {
|
|
11
|
+
...option,
|
|
12
|
+
previous,
|
|
13
|
+
next: undefined,
|
|
14
|
+
index,
|
|
15
|
+
};
|
|
16
|
+
if (previous) {
|
|
17
|
+
previous.next = item;
|
|
18
|
+
}
|
|
19
|
+
if (!firstItem) {
|
|
20
|
+
firstItem = item;
|
|
21
|
+
}
|
|
22
|
+
items.push([option.value, item]);
|
|
23
|
+
index++;
|
|
24
|
+
previous = item;
|
|
25
|
+
}
|
|
26
|
+
super(items);
|
|
27
|
+
this.first = firstItem;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const reducer = (state, action) => {
|
|
31
|
+
switch (action.type) {
|
|
32
|
+
case 'select-next-option': {
|
|
33
|
+
if (typeof state.value === 'undefined') {
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
const item = state.optionMap.get(state.value);
|
|
37
|
+
if (!item) {
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
let next = item.next;
|
|
41
|
+
while (next && next.disabled) {
|
|
42
|
+
next = next.next;
|
|
43
|
+
}
|
|
44
|
+
if (!next) {
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
const needsToScroll = next.index >= state.visibleToIndex;
|
|
48
|
+
if (!needsToScroll) {
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
value: next.value,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const nextVisibleToIndex = Math.min(state.optionMap.size, state.visibleToIndex + 1);
|
|
55
|
+
const nextVisibleFromIndex = nextVisibleToIndex - state.visibleOptionCount;
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
value: next.value,
|
|
59
|
+
visibleFromIndex: nextVisibleFromIndex,
|
|
60
|
+
visibleToIndex: nextVisibleToIndex,
|
|
61
|
+
previousValue: state.value,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
case 'select-previous-option': {
|
|
65
|
+
if (typeof state.value === 'undefined') {
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
const item = state.optionMap.get(state.value);
|
|
69
|
+
if (!item) {
|
|
70
|
+
return state;
|
|
71
|
+
}
|
|
72
|
+
let previous = item.previous;
|
|
73
|
+
while (previous && previous.disabled) {
|
|
74
|
+
previous = previous.previous;
|
|
75
|
+
}
|
|
76
|
+
if (!previous) {
|
|
77
|
+
return state;
|
|
78
|
+
}
|
|
79
|
+
const needsToScroll = previous.index <= state.visibleFromIndex;
|
|
80
|
+
if (!needsToScroll) {
|
|
81
|
+
return {
|
|
82
|
+
...state,
|
|
83
|
+
value: previous.value,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const nextVisibleFromIndex = Math.max(0, state.visibleFromIndex - 1);
|
|
87
|
+
const nextVisibleToIndex = nextVisibleFromIndex + state.visibleOptionCount;
|
|
88
|
+
return {
|
|
89
|
+
...state,
|
|
90
|
+
value: previous.value,
|
|
91
|
+
visibleFromIndex: nextVisibleFromIndex,
|
|
92
|
+
visibleToIndex: nextVisibleToIndex,
|
|
93
|
+
previousValue: state.value,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case 'select-option': {
|
|
97
|
+
const item = state.optionMap.get(action.option.value);
|
|
98
|
+
if (!item) {
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
...state,
|
|
103
|
+
value: item.value,
|
|
104
|
+
previousValue: state.value,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
case 'reset': {
|
|
108
|
+
return action.state;
|
|
109
|
+
}
|
|
110
|
+
default: {
|
|
111
|
+
return state;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const createDefaultState = ({ visibleOptionCount: customVisibleOptionCount, defaultValue, options, }) => {
|
|
116
|
+
const visibleOptionCount = typeof customVisibleOptionCount === 'number' ? Math.min(customVisibleOptionCount, options.length) : options.length;
|
|
117
|
+
const optionMap = new OptionMap(options);
|
|
118
|
+
const defaultOption = typeof defaultValue === 'undefined' ? undefined : optionMap.get(defaultValue);
|
|
119
|
+
let option = defaultOption && !defaultOption.disabled ? defaultOption : optionMap.first;
|
|
120
|
+
while (option && option.disabled) {
|
|
121
|
+
option = option.next;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
optionMap,
|
|
125
|
+
visibleOptionCount,
|
|
126
|
+
visibleFromIndex: 0,
|
|
127
|
+
visibleToIndex: visibleOptionCount,
|
|
128
|
+
value: option?.value,
|
|
129
|
+
previousValue: option?.value,
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export const useSelectState = ({ visibleOptionCount, options, defaultValue }) => {
|
|
133
|
+
const [state, dispatch] = useReducer(reducer, { visibleOptionCount, defaultValue, options }, createDefaultState);
|
|
134
|
+
const [lastOptions, setLastOptions] = useState(options);
|
|
135
|
+
const [lastVisibleOptionCount, setLastVisibleOptionCount] = useState(visibleOptionCount);
|
|
136
|
+
if (options !== lastOptions && !isDeepStrictEqual(options, lastOptions)) {
|
|
137
|
+
dispatch({
|
|
138
|
+
type: 'reset',
|
|
139
|
+
state: createDefaultState({ visibleOptionCount, defaultValue, options }),
|
|
140
|
+
});
|
|
141
|
+
setLastOptions(options);
|
|
142
|
+
}
|
|
143
|
+
if (visibleOptionCount !== lastVisibleOptionCount) {
|
|
144
|
+
dispatch({
|
|
145
|
+
type: 'reset',
|
|
146
|
+
state: createDefaultState({ visibleOptionCount, defaultValue, options }),
|
|
147
|
+
});
|
|
148
|
+
setLastVisibleOptionCount(visibleOptionCount);
|
|
149
|
+
}
|
|
150
|
+
const selectNextOption = useCallback(() => {
|
|
151
|
+
dispatch({
|
|
152
|
+
type: 'select-next-option',
|
|
153
|
+
});
|
|
154
|
+
}, []);
|
|
155
|
+
const selectPreviousOption = useCallback(() => {
|
|
156
|
+
dispatch({
|
|
157
|
+
type: 'select-previous-option',
|
|
158
|
+
});
|
|
159
|
+
}, []);
|
|
160
|
+
const selectOption = useCallback(({ option }) => {
|
|
161
|
+
dispatch({
|
|
162
|
+
type: 'select-option',
|
|
163
|
+
option,
|
|
164
|
+
});
|
|
165
|
+
}, []);
|
|
166
|
+
const visibleOptions = useMemo(() => {
|
|
167
|
+
return options.slice(state.visibleFromIndex, state.visibleToIndex);
|
|
168
|
+
}, [options, state.visibleFromIndex, state.visibleToIndex]);
|
|
169
|
+
return {
|
|
170
|
+
visibleFromIndex: state.visibleFromIndex,
|
|
171
|
+
visibleToIndex: state.visibleToIndex,
|
|
172
|
+
value: state.value,
|
|
173
|
+
visibleOptions,
|
|
174
|
+
selectNextOption,
|
|
175
|
+
selectPreviousOption,
|
|
176
|
+
selectOption,
|
|
177
|
+
previousValue: state.previousValue,
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=use-select-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-select-state.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/hooks/use-select-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAChE,OAAO,EAAC,iBAAiB,EAAC,MAAM,WAAW,CAAA;AAU3C,MAAM,CAAC,OAAO,OAAO,SAAa,SAAQ,GAAwB;IAGhE,YAAY,OAAoB;QAC9B,MAAM,KAAK,GAA4B,EAAE,CAAA;QACzC,IAAI,SAAuC,CAAA;QAC3C,IAAI,QAAsC,CAAA;QAC1C,IAAI,KAAK,GAAG,CAAC,CAAA;QAEb,KAAK,MAAM,MAAM,IAAI,OAAO,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GAAG,WAAW,CAAC,GAAG,EAAE;QACxC,QAAQ,CAAC;YACP,IAAI,EAAE,oBAAoB;SAC3B,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5C,QAAQ,CAAC;YACP,IAAI,EAAE,wBAAwB;SAC/B,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,EAAC,MAAM,EAAsB,EAAE,EAAE;QACjE,QAAQ,CAAC;YACP,IAAI,EAAE,eAAe;YACrB,MAAM;SACP,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IACpE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;IAE3D,OAAO;QACL,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,cAAc;QACd,gBAAgB;QAChB,oBAAoB;QACpB,YAAY;QACZ,aAAa,EAAE,KAAK,CAAC,aAAa;KACnC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {ItemWithKey} from '../components/SelectInput.js'\nimport {useReducer, useCallback, useMemo, useState} from 'react'\nimport {isDeepStrictEqual} from 'node:util'\n\ntype Option<T> = ItemWithKey<T>\n\ntype OptionMapItem<T> = Option<T> & {\n previous: OptionMapItem<T> | undefined\n next: OptionMapItem<T> | undefined\n index: number\n}\n\nexport default class OptionMap<T> extends Map<T, OptionMapItem<T>> {\n readonly first: OptionMapItem<T> | undefined\n\n constructor(options: Option<T>[]) {\n const items: [T, OptionMapItem<T>][] = []\n let firstItem: OptionMapItem<T> | undefined\n let previous: OptionMapItem<T> | undefined\n let index = 0\n\n for (const option of options) {\n const item = {\n ...option,\n previous,\n next: undefined,\n index,\n }\n\n if (previous) {\n previous.next = item\n }\n\n if (!firstItem) {\n firstItem = item\n }\n\n items.push([option.value, item])\n index++\n previous = item\n }\n\n super(items)\n this.first = firstItem\n }\n}\n\ninterface State<T> {\n /**\n * Map where key is option's value and value is option's index.\n */\n optionMap: OptionMap<T>\n\n /**\n * Number of visible options.\n */\n visibleOptionCount: number\n\n /**\n * Index of the first visible option.\n */\n visibleFromIndex: number\n\n /**\n * Index of the last visible option.\n */\n visibleToIndex: number\n\n /**\n * Value of the previously selected option.\n */\n previousValue: T | undefined\n\n /**\n * Value of the selected option.\n */\n value: T | undefined\n}\n\ntype Action<T> = SelectNextOptionAction<T> | SelectPreviousOptionAction<T> | SelectOptionAction<T> | ResetAction<T>\n\ninterface SelectNextOptionAction<T> {\n type: 'select-next-option'\n}\n\ninterface SelectPreviousOptionAction<T> {\n type: 'select-previous-option'\n}\n\ninterface SelectOptionAction<T> {\n type: 'select-option'\n option: Option<T>\n}\n\ninterface ResetAction<T> {\n type: 'reset'\n state: State<T>\n}\n\nconst reducer = <T>(state: State<T>, action: Action<T>): State<T> => {\n switch (action.type) {\n case 'select-next-option': {\n if (typeof state.value === 'undefined') {\n return state\n }\n\n const item = state.optionMap.get(state.value)\n\n if (!item) {\n return state\n }\n\n let next = item.next\n\n while (next && next.disabled) {\n next = next.next\n }\n\n if (!next) {\n return state\n }\n\n const needsToScroll = next.index >= state.visibleToIndex\n\n if (!needsToScroll) {\n return {\n ...state,\n value: next.value,\n }\n }\n\n const nextVisibleToIndex = Math.min(state.optionMap.size, state.visibleToIndex + 1)\n const nextVisibleFromIndex = nextVisibleToIndex - state.visibleOptionCount\n\n return {\n ...state,\n value: next.value,\n visibleFromIndex: nextVisibleFromIndex,\n visibleToIndex: nextVisibleToIndex,\n previousValue: state.value,\n }\n }\n\n case 'select-previous-option': {\n if (typeof state.value === 'undefined') {\n return state\n }\n\n const item = state.optionMap.get(state.value)\n\n if (!item) {\n return state\n }\n\n let previous = item.previous\n\n while (previous && previous.disabled) {\n previous = previous.previous\n }\n\n if (!previous) {\n return state\n }\n\n const needsToScroll = previous.index <= state.visibleFromIndex\n\n if (!needsToScroll) {\n return {\n ...state,\n value: previous.value,\n }\n }\n\n const nextVisibleFromIndex = Math.max(0, state.visibleFromIndex - 1)\n const nextVisibleToIndex = nextVisibleFromIndex + state.visibleOptionCount\n\n return {\n ...state,\n value: previous.value,\n visibleFromIndex: nextVisibleFromIndex,\n visibleToIndex: nextVisibleToIndex,\n previousValue: state.value,\n }\n }\n\n case 'select-option': {\n const item = state.optionMap.get(action.option.value)\n\n if (!item) {\n return state\n }\n\n return {\n ...state,\n value: item.value,\n previousValue: state.value,\n }\n }\n\n case 'reset': {\n return action.state\n }\n\n default: {\n return state\n }\n }\n}\n\nexport interface UseSelectStateProps<T> {\n /**\n * Number of items to display.\n *\n */\n visibleOptionCount?: number\n\n /**\n * Options.\n */\n options: Option<T>[]\n\n /**\n * Initially selected option's value.\n */\n defaultValue?: T\n}\n\nexport type SelectState<T> = Pick<State<T>, 'visibleFromIndex' | 'visibleToIndex' | 'value'> & {\n /**\n * Visible options.\n */\n visibleOptions: (Option<T> & {index: number})[]\n\n /**\n * Select next option and scroll the list down, if needed.\n */\n selectNextOption: () => void\n\n /**\n * Select previous option and scroll the list up, if needed.\n */\n selectPreviousOption: () => void\n\n /**\n * Select option directly.\n */\n selectOption: (option: Option<T>) => void\n}\n\ntype CreateDefaultStateProps<T> = Pick<UseSelectStateProps<T>, 'visibleOptionCount' | 'defaultValue' | 'options'>\n\nconst createDefaultState = <T>({\n visibleOptionCount: customVisibleOptionCount,\n defaultValue,\n options,\n}: CreateDefaultStateProps<T>) => {\n const visibleOptionCount =\n typeof customVisibleOptionCount === 'number' ? Math.min(customVisibleOptionCount, options.length) : options.length\n\n const optionMap = new OptionMap(options)\n\n const defaultOption = typeof defaultValue === 'undefined' ? undefined : optionMap.get(defaultValue)\n\n let option = defaultOption && !defaultOption.disabled ? defaultOption : optionMap.first\n\n while (option && option.disabled) {\n option = option.next\n }\n\n return {\n optionMap,\n visibleOptionCount,\n visibleFromIndex: 0,\n visibleToIndex: visibleOptionCount,\n value: option?.value,\n previousValue: option?.value,\n }\n}\n\nexport const useSelectState = <T>({visibleOptionCount, options, defaultValue}: UseSelectStateProps<T>) => {\n const [state, dispatch] = useReducer(reducer, {visibleOptionCount, defaultValue, options}, createDefaultState)\n const [lastOptions, setLastOptions] = useState(options)\n const [lastVisibleOptionCount, setLastVisibleOptionCount] = useState(visibleOptionCount)\n\n if (options !== lastOptions && !isDeepStrictEqual(options, lastOptions)) {\n dispatch({\n type: 'reset',\n state: createDefaultState({visibleOptionCount, defaultValue, options}),\n })\n\n setLastOptions(options)\n }\n\n if (visibleOptionCount !== lastVisibleOptionCount) {\n dispatch({\n type: 'reset',\n state: createDefaultState({visibleOptionCount, defaultValue, options}),\n })\n\n setLastVisibleOptionCount(visibleOptionCount)\n }\n\n const selectNextOption = useCallback(() => {\n dispatch({\n type: 'select-next-option',\n })\n }, [])\n\n const selectPreviousOption = useCallback(() => {\n dispatch({\n type: 'select-previous-option',\n })\n }, [])\n\n const selectOption = useCallback(({option}: {option: Option<T>}) => {\n dispatch({\n type: 'select-option',\n option,\n })\n }, [])\n\n const visibleOptions = useMemo(() => {\n return options.slice(state.visibleFromIndex, state.visibleToIndex)\n }, [options, state.visibleFromIndex, state.visibleToIndex])\n\n return {\n visibleFromIndex: state.visibleFromIndex,\n visibleToIndex: state.visibleToIndex,\n value: state.value,\n visibleOptions,\n selectNextOption,\n selectPreviousOption,\n selectOption,\n previousValue: state.previousValue,\n }\n}\n"]}
|
package/dist/private/node/ui.js
CHANGED
|
@@ -33,8 +33,9 @@ export class Stdout extends EventEmitter {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
const renderString = (element, renderOptions) => {
|
|
36
|
+
const columns = isUnitTest() ? 80 : process.stdout.columns;
|
|
36
37
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
const stdout = renderOptions?.stdout ?? new Stdout({ columns
|
|
38
|
+
const stdout = renderOptions?.stdout ?? new Stdout({ columns });
|
|
38
39
|
const instance = inkRender(element, {
|
|
39
40
|
stdout,
|
|
40
41
|
debug: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,6BAA6B,CAAA;AAC5G,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAE7D,OAAO,EAAM,MAAM,IAAI,SAAS,EAAgB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAQnC,MAAM,UAAU,UAAU,CACxB,OAAoB,EACpB,EAAC,QAAQ,GAAG,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,aAAa,EAAoB;IAE1E,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IAE9D,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC9C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,CAAA;KACtE;IAED,OAAO,EAAE,CAAA;IAET,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,OAAuB;IAClE,MAAM,EAAC,aAAa,EAAC,GAAG,SAAS,CAA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M,GAAI,aAAa,EAAE,MAAc,IAAI,IAAI,MAAM,CAAC,EAAC,OAAO,EAAC,CAAC,CAAA;IAEtE,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,MAAM;QACN,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAQ;IACjD,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;QAC7B,gEAAgE;QAChE,QAAQ,CAAC,QAAQ,CAAC,CAAA;KACnB;AACH,CAAC","sourcesContent":["import {treeKill} from './tree-kill.js'\nimport {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../public/node/output.js'\nimport {isUnitTest} from '../../public/node/context/local.js'\nimport {ReactElement} from 'react'\nimport {Key, render as inkRender, RenderOptions} from 'ink'\nimport {EventEmitter} from 'events'\n\ninterface RenderOnceOptions {\n logLevel?: LogLevel\n logger?: Logger\n renderOptions?: RenderOptions\n}\n\nexport function renderOnce(\n element: JSX.Element,\n {logLevel = 'info', logger = consoleLog, renderOptions}: RenderOnceOptions,\n) {\n const {output, unmount} = renderString(element, renderOptions)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output, {skipUIEvent: true})\n }\n\n unmount()\n\n return output\n}\n\nexport function render(element: JSX.Element, options?: RenderOptions) {\n const {waitUntilExit} = inkRender(element, options)\n return waitUntilExit()\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nexport class Stdout extends EventEmitter {\n columns: number\n rows: number\n readonly frames: string[] = []\n private _lastFrame?: string\n\n constructor(options: {columns?: number; rows?: number}) {\n super()\n this.columns = options.columns ?? 80\n this.rows = options.rows ?? 80\n }\n\n write = (frame: string) => {\n this.frames.push(frame)\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nconst renderString = (element: ReactElement, renderOptions?: RenderOptions): Instance => {\n const columns = isUnitTest() ? 80 : process.stdout.columns\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stdout = (renderOptions?.stdout as any) ?? new Stdout({columns})\n\n const instance = inkRender(element, {\n stdout,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n\nexport function handleCtrlC(input: string, key: Key) {\n if (input === 'c' && key.ctrl) {\n // Exceptions thrown in hooks aren't caught by our errorHandler.\n treeKill('SIGINT')\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_KIT_VERSION = "3.
|
|
1
|
+
export declare const CLI_KIT_VERSION = "3.47.0-pre.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLI_KIT_VERSION = '3.
|
|
1
|
+
export const CLI_KIT_VERSION = '3.47.0-pre.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.47.0-pre.0'\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraphQLVariables } from './graphql.js';
|
|
2
|
+
/**
|
|
3
|
+
* Executes a GraphQL query against the Business Platform API.
|
|
4
|
+
*
|
|
5
|
+
* @param query - GraphQL query to execute.
|
|
6
|
+
* @param token - Business Platform token.
|
|
7
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
8
|
+
* @returns The response of the query of generic type <T>.
|
|
9
|
+
*/
|
|
10
|
+
export declare function businessPlatformRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { graphqlRequest } from './graphql.js';
|
|
2
|
+
import { handleDeprecations } from './partners.js';
|
|
3
|
+
import { businessPlatformFqdn } from '../context/fqdn.js';
|
|
4
|
+
/**
|
|
5
|
+
* Executes a GraphQL query against the Business Platform API.
|
|
6
|
+
*
|
|
7
|
+
* @param query - GraphQL query to execute.
|
|
8
|
+
* @param token - Business Platform token.
|
|
9
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
10
|
+
* @returns The response of the query of generic type <T>.
|
|
11
|
+
*/
|
|
12
|
+
export async function businessPlatformRequest(query, token, variables) {
|
|
13
|
+
const api = 'BusinessPlatform';
|
|
14
|
+
const fqdn = await businessPlatformFqdn();
|
|
15
|
+
const url = `https://${fqdn}/destinations/api/2020-07/graphql`;
|
|
16
|
+
return graphqlRequest({
|
|
17
|
+
query,
|
|
18
|
+
api,
|
|
19
|
+
url,
|
|
20
|
+
token,
|
|
21
|
+
variables,
|
|
22
|
+
responseOptions: { onResponse: handleDeprecations },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=business-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"business-platform.js","sourceRoot":"","sources":["../../../../src/public/node/api/business-platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAC,MAAM,cAAc,CAAA;AAC7D,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAA;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAa,EACb,KAAa,EACb,SAA4B;IAE5B,MAAM,GAAG,GAAG,kBAAkB,CAAA;IAC9B,MAAM,IAAI,GAAG,MAAM,oBAAoB,EAAE,CAAA;IACzC,MAAM,GAAG,GAAG,WAAW,IAAI,mCAAmC,CAAA;IAC9D,OAAO,cAAc,CAAC;QACpB,KAAK;QACL,GAAG;QACH,GAAG;QACH,KAAK;QACL,SAAS;QACT,eAAe,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC;KAClD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {GraphQLVariables, graphqlRequest} from './graphql.js'\nimport {handleDeprecations} from './partners.js'\nimport {businessPlatformFqdn} from '../context/fqdn.js'\n\n/**\n * Executes a GraphQL query against the Business Platform API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Business Platform token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function businessPlatformRequest<T>(\n query: string,\n token: string,\n variables?: GraphQLVariables,\n): Promise<T> {\n const api = 'BusinessPlatform'\n const fqdn = await businessPlatformFqdn()\n const url = `https://${fqdn}/destinations/api/2020-07/graphql`\n return graphqlRequest({\n query,\n api,\n url,\n token,\n variables,\n responseOptions: {onResponse: handleDeprecations},\n })\n}\n"]}
|
|
@@ -9,6 +9,12 @@ export declare const NotProvidedStoreFQDNError: AbortError;
|
|
|
9
9
|
* @returns Fully-qualified domain of the partners service we should interact with.
|
|
10
10
|
*/
|
|
11
11
|
export declare function partnersFqdn(): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* It returns the BusinessPlatform' API service we should interact with.
|
|
14
|
+
*
|
|
15
|
+
* @returns Fully-qualified domain of the partners service we should interact with.
|
|
16
|
+
*/
|
|
17
|
+
export declare function businessPlatformFqdn(): Promise<string>;
|
|
12
18
|
/**
|
|
13
19
|
* It returns the Identity service we should interact with.
|
|
14
20
|
*
|
|
@@ -22,6 +22,23 @@ export async function partnersFqdn() {
|
|
|
22
22
|
return productionFqdn;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* It returns the BusinessPlatform' API service we should interact with.
|
|
27
|
+
*
|
|
28
|
+
* @returns Fully-qualified domain of the partners service we should interact with.
|
|
29
|
+
*/
|
|
30
|
+
export async function businessPlatformFqdn() {
|
|
31
|
+
const environment = serviceEnvironment();
|
|
32
|
+
const productionFqdn = 'destinations.shopifysvc.com';
|
|
33
|
+
switch (environment) {
|
|
34
|
+
case 'local':
|
|
35
|
+
return 'business-platform.myshopify.io';
|
|
36
|
+
case 'spin':
|
|
37
|
+
return `business-platform.${await spinFqdn()}`;
|
|
38
|
+
default:
|
|
39
|
+
return productionFqdn;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
25
42
|
/**
|
|
26
43
|
* It returns the Identity service we should interact with.
|
|
27
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/context/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAE3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,UAAU,CAC9D,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,UAAU,CAC9D,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,UAAU,CAC7D,gGAAgG,CACjG,CAAA;AACD,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,UAAU,CACrD,2EAA2E,CAC5E,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAa;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtE,MAAM,SAAS,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE,CAC5C,iBAAiB,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,gBAAgB,CAAA;IACjG,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACnH,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {isSpinEnvironment, spinFqdn} from './spin.js'\nimport {AbortError} from '../error.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return 'partners.myshopify.io'\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return 'identity.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) =>\n isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`\n const containDomain = (storeFqdn: string) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fqd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,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAa;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtE,MAAM,SAAS,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE,CAC5C,iBAAiB,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,gBAAgB,CAAA;IACjG,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACnH,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {isSpinEnvironment, spinFqdn} from './spin.js'\nimport {AbortError} from '../error.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return 'partners.myshopify.io'\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the BusinessPlatform' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function businessPlatformFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'destinations.shopifysvc.com'\n switch (environment) {\n case 'local':\n return 'business-platform.myshopify.io'\n case 'spin':\n return `business-platform.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return 'identity.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) =>\n isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`\n const containDomain = (storeFqdn: string) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
|
|
@@ -27,7 +27,7 @@ export type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic
|
|
|
27
27
|
export declare function createRuntimeMetadataContainer<TPublic extends AnyJson, TSensitive extends AnyJson = {
|
|
28
28
|
[key: string]: never;
|
|
29
29
|
}>(): RuntimeMetadataManager<TPublic, TSensitive>;
|
|
30
|
-
type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & PickByPrefix<MonorailEventPublic, 'cmd_app_'>;
|
|
30
|
+
type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & PickByPrefix<MonorailEventPublic, 'cmd_app_'> & PickByPrefix<MonorailEventPublic, 'cmd_create_app_'>;
|
|
31
31
|
declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
|
|
32
32
|
commandStartOptions: {
|
|
33
33
|
startTime: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/public/node/metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAc7C;;;;GAIG;AACH,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAmBD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IACD,MAAM,YAAY,GAAG,CAAC,IAAyB,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GA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QACL,oBAAoB,EAAE,GAAG,EAAE;YACzB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,uBAAuB,EAAE,GAAG,EAAE;YAC5B,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;QACD,iBAAiB,EAAE,KAAK,EAAE,OAAiC,EAAE,UAAiC,MAAM,EAAE,EAAE;YACtG,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;QACD,oBAAoB,EAAE,KAAK,EAAE,OAAoC,EAAE,UAAiC,MAAM,EAAE,EAAE;YAC5G,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAQD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './error-handler.js'\nimport {isUnitTest} from './context/local.js'\nimport {PickByPrefix} from '../common/ts/pick-by-prefix.js'\nimport {AnyJson} from '../../private/common/json.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\n/**\n * Get the error handling strategy for metadata.\n *\n * @returns 'mute-and-report' in production, 'bubble' in tests.\n */\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII. */\n addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /**\n * Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked\n * (this is a good fit for command args for instance).\n */\n addSensitiveMetadata: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data. */\n getAllPublicMetadata: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data. */\n getAllSensitiveMetadata: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n * @returns A container for the metadata.\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublicMetadata: () => {\n return {...raw.public}\n },\n getAllSensitiveMetadata: () => {\n return {...raw.sensitive}\n },\n addPublicMetadata: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitiveMetadata: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_create_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n } & {environmentFlags: string}\n>()\n\nexport const {getAllPublicMetadata, getAllSensitiveMetadata, addPublicMetadata, addSensitiveMetadata} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
|
|
@@ -2,7 +2,7 @@ import { JsonMap } from '../../private/common/json.js';
|
|
|
2
2
|
import { DeepRequired } from '../common/ts/deep-required.js';
|
|
3
3
|
export { DeepRequired };
|
|
4
4
|
type Optional<T> = T | null;
|
|
5
|
-
export declare const MONORAIL_COMMAND_TOPIC: "app_cli3_command/1.
|
|
5
|
+
export declare const MONORAIL_COMMAND_TOPIC: "app_cli3_command/1.4";
|
|
6
6
|
export interface Schemas {
|
|
7
7
|
[MONORAIL_COMMAND_TOPIC]: {
|
|
8
8
|
sensitive: {
|
|
@@ -51,6 +51,7 @@ export interface Schemas {
|
|
|
51
51
|
cmd_dev_tunnel_type?: Optional<string>;
|
|
52
52
|
cmd_dev_tunnel_custom_hash?: Optional<string>;
|
|
53
53
|
cmd_dev_urls_updated?: Optional<boolean>;
|
|
54
|
+
cmd_create_app_template?: Optional<string>;
|
|
54
55
|
app_extensions_any?: Optional<boolean>;
|
|
55
56
|
app_extensions_breakdown?: Optional<string>;
|
|
56
57
|
app_extensions_count?: Optional<number>;
|
|
@@ -2,7 +2,7 @@ import { fetch } from './http.js';
|
|
|
2
2
|
import { outputDebug, outputContent, outputToken } from '../../public/node/output.js';
|
|
3
3
|
const url = 'https://monorail-edge.shopifysvc.com/v1/produce';
|
|
4
4
|
// This is the topic name of the main event we log to Monorail, the command tracker
|
|
5
|
-
export const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.
|
|
5
|
+
export const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.4';
|
|
6
6
|
/**
|
|
7
7
|
* Publishes an event to Monorail.
|
|
8
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../../../src/public/node/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAKnF,MAAM,GAAG,GAAG,iDAAiD,CAAA;AAI7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../../../src/public/node/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAKnF,MAAM,GAAG,GAAG,iDAAiD,CAAA;AAI7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAA+B,CAAA;AAmHrE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAmB,EACnB,UAA8B,EAC9B,aAAoC;IAEpC,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,IAAI,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AQ,EAAE;KAC3D,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {fetch} from './http.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport {DeepRequired} from '../common/ts/deep-required.js'\n\nexport {DeepRequired}\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\ntype Optional<T> = T | null\n\n// This is the topic name of the main event we log to Monorail, the command tracker\nexport const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.4' as const\n\nexport interface Schemas {\n [MONORAIL_COMMAND_TOPIC]: {\n sensitive: {\n args: string\n error_message?: Optional<string>\n app_name?: Optional<string>\n metadata?: Optional<string>\n store_fqdn?: Optional<string>\n cmd_all_environment_flags?: Optional<string>\n\n // Dev related commands\n cmd_dev_tunnel_custom?: Optional<string>\n\n // Environment\n env_plugin_installed_all?: Optional<string>\n }\n public: {\n partner_id?: Optional<number>\n command: string\n project_type?: Optional<string>\n time_start: number\n time_end: number\n total_time: number\n success: boolean\n api_key?: Optional<string>\n cli_version: string\n uname: string\n ruby_version: string\n node_version: string\n is_employee: boolean\n store_fqdn_hash?: Optional<string>\n\n // Any and all commands\n cmd_all_alias_used?: Optional<string>\n cmd_all_launcher?: Optional<string>\n cmd_all_path_override?: Optional<boolean>\n cmd_all_path_override_hash?: Optional<string>\n cmd_all_plugin?: Optional<string>\n cmd_all_topic?: Optional<string>\n cmd_all_verbose?: Optional<boolean>\n\n // Any extension related command\n cmd_extensions_binary_from_source?: Optional<boolean>\n\n // Scaffolding related commands\n cmd_scaffold_required_auth?: Optional<boolean>\n cmd_scaffold_template_custom?: Optional<boolean>\n cmd_scaffold_template_flavor?: Optional<string>\n cmd_scaffold_type?: Optional<string>\n cmd_scaffold_type_category?: Optional<string>\n cmd_scaffold_type_gated?: Optional<boolean>\n cmd_scaffold_type_owner?: Optional<string>\n cmd_scaffold_used_prompts_for_type?: Optional<boolean>\n\n // Used in several but not all commands\n cmd_app_dependency_installation_skipped?: Optional<boolean>\n cmd_app_reset_used?: Optional<boolean>\n\n // Dev related commands\n cmd_dev_tunnel_type?: Optional<string>\n cmd_dev_tunnel_custom_hash?: Optional<string>\n cmd_dev_urls_updated?: Optional<boolean>\n\n // Create-app related commands\n cmd_create_app_template?: Optional<string>\n\n // App setup\n app_extensions_any?: Optional<boolean>\n app_extensions_breakdown?: Optional<string>\n app_extensions_count?: Optional<number>\n app_extensions_custom_layout?: Optional<boolean>\n app_extensions_function_any?: Optional<boolean>\n app_extensions_function_count?: Optional<number>\n app_extensions_function_custom_layout?: Optional<boolean>\n app_extensions_theme_any?: Optional<boolean>\n app_extensions_theme_count?: Optional<number>\n app_extensions_theme_custom_layout?: Optional<boolean>\n app_extensions_ui_any?: Optional<boolean>\n app_extensions_ui_count?: Optional<number>\n app_extensions_ui_custom_layout?: Optional<boolean>\n app_name_hash?: Optional<string>\n app_path_hash?: Optional<string>\n app_scopes?: Optional<string>\n app_web_backend_any?: Optional<boolean>\n app_web_backend_count?: Optional<number>\n app_web_custom_layout?: Optional<boolean>\n app_web_framework?: Optional<string>\n app_web_frontend_any?: Optional<boolean>\n app_web_frontend_count?: Optional<number>\n\n // Environment\n env_ci?: Optional<boolean>\n env_ci_platform?: Optional<string>\n env_device_id?: Optional<string>\n env_package_manager?: Optional<string>\n env_package_manager_workspaces?: Optional<boolean>\n env_plugin_installed_any_custom?: Optional<boolean>\n env_plugin_installed_shopify?: Optional<string>\n env_shell?: Optional<string>\n env_web_ide?: Optional<string>\n env_cloud?: Optional<string>\n }\n }\n [schemaId: string]: {sensitive: JsonMap; public: JsonMap}\n}\n\n// In reality, we're normally most interested in just this from Schemas, so export it for ease of use.\n// The monorail schema itself has lots of optional values as it must be backwards-compatible. For our schema we want mandatory values instead.\nexport type MonorailEventPublic = DeepRequired<Schemas[typeof MONORAIL_COMMAND_TOPIC]['public']>\nexport type MonorailEventSensitive = Schemas[typeof MONORAIL_COMMAND_TOPIC]['sensitive']\n\ntype MonorailResult = {type: 'ok'} | {type: 'error'; message: string}\n\n/**\n * Publishes an event to Monorail.\n *\n * @param schemaId - The schema ID of the event to publish.\n * @param publicData - The public data to publish.\n * @param sensitiveData - The sensitive data to publish.\n * @returns A result indicating whether the event was successfully published.\n */\nexport async function publishMonorailEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(\n schemaId: TSchemaId,\n publicData: TPayload['public'],\n sensitiveData: TPayload['sensitive'],\n): Promise<MonorailResult> {\n try {\n const currentTime = new Date().getTime()\n const payload = {...publicData, ...sensitiveData}\n const body = JSON.stringify({schema_id: schemaId, payload})\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n\n if (response.status === 200) {\n outputDebug(outputContent`Analytics event sent: ${outputToken.json(payload)}`)\n return {type: 'ok'}\n } else {\n outputDebug(`Failed to report usage analytics: ${response.statusText}`)\n return {type: 'error', message: response.statusText}\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n outputDebug(message)\n return {type: 'error', message}\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n"]}
|
|
@@ -46,6 +46,13 @@ export declare function ensureAuthenticatedAdmin(store: string, scopes?: string[
|
|
|
46
46
|
* @returns The access token and store.
|
|
47
47
|
*/
|
|
48
48
|
export declare function ensureAuthenticatedThemes(store: string, password: string | undefined, scopes?: string[], forceRefresh?: boolean): Promise<AdminSession>;
|
|
49
|
+
/**
|
|
50
|
+
* Ensure that we have a valid session to access the Business Platform API.
|
|
51
|
+
*
|
|
52
|
+
* @param scopes - Optional array of extra scopes to authenticate with.
|
|
53
|
+
* @returns The access token for the Business Platform API.
|
|
54
|
+
*/
|
|
55
|
+
export declare function ensureAuthenticatedBusinessPlatform(scopes?: string[]): Promise<string>;
|
|
49
56
|
/**
|
|
50
57
|
* Logout from Shopify.
|
|
51
58
|
*
|
|
@@ -85,6 +85,22 @@ ${outputToken.json(scopes)}
|
|
|
85
85
|
return { token: password, storeFqdn: await normalizeStoreFqdn(store) };
|
|
86
86
|
return ensureAuthenticatedAdmin(store, scopes, forceRefresh);
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Ensure that we have a valid session to access the Business Platform API.
|
|
90
|
+
*
|
|
91
|
+
* @param scopes - Optional array of extra scopes to authenticate with.
|
|
92
|
+
* @returns The access token for the Business Platform API.
|
|
93
|
+
*/
|
|
94
|
+
export async function ensureAuthenticatedBusinessPlatform(scopes = []) {
|
|
95
|
+
outputDebug(outputContent `Ensuring that the user is authenticated with the Business Platform API with the following scopes:
|
|
96
|
+
${outputToken.json(scopes)}
|
|
97
|
+
`);
|
|
98
|
+
const tokens = await ensureAuthenticated({ businessPlatformApi: { scopes } }, process.env);
|
|
99
|
+
if (!tokens.businessPlatform) {
|
|
100
|
+
throw new BugError('No business-platform token found after ensuring authenticated');
|
|
101
|
+
}
|
|
102
|
+
return tokens.businessPlatform;
|
|
103
|
+
}
|
|
88
104
|
/**
|
|
89
105
|
* Logout from Shopify.
|
|
90
106
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6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M,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAa,EACb,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,WAAW,CAAC,aAAa,CAAA,sGAAsG,WAAW,CAAC,GAAG,CAC5I,KAAK,CACN;EACD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;CACzB,CAAC,CAAA;IACA,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,EAAC,EAAE,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;IAC3G,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,MAAM,IAAI,QAAQ,CAAC,mDAAmD,CAAC,CAAA;KACxE;IACD,OAAO,MAAM,CAAC,KAAK,CAAA;AACrB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,KAAa,EACb,QAA4B,EAC5B,SAAmB,EAAE,EACrB,YAAY,GAAG,KAAK;IAEpB,WAAW,CAAC,aAAa,CAAA;EACzB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;CACzB,CAAC,CAAA;IACA,IAAI,QAAQ;QAAE,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAAC,CAAA;IAClF,OAAO,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './context/fqdn.js'\nimport {BugError} from './error.js'\nimport {getPartnersToken} from './environment.js'\nimport * as secureStore from '../../private/node/session/store.js'\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {ensureAuthenticated} from '../../private/node/session.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param _env - Optional environment variables to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(scopes: string[] = [], _env = process.env): Promise<string> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const envToken = getPartnersToken()\n if (envToken) {\n return (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}})\n if (!tokens.partners) {\n throw new BugError('No partners token found after ensuring authenticated')\n }\n return tokens.partners\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n forceRefresh = false,\n): Promise<string> {\n if (password) return password\n\n outputDebug(outputContent`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}}, process.env, forceRefresh)\n if (!tokens.storefront) {\n throw new BugError('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${outputToken.raw(\n store,\n )}:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)\n if (!tokens.admin) {\n throw new BugError('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${outputToken.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,O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AC,MAAM,CAAC,gBAAgB,EAAE;QAC5B,MAAM,IAAI,QAAQ,CAAC,+DAA+D,CAAC,CAAA;KACpF;IACD,OAAO,MAAM,CAAC,gBAAgB,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './context/fqdn.js'\nimport {BugError} from './error.js'\nimport {getPartnersToken} from './environment.js'\nimport * as secureStore from '../../private/node/session/store.js'\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {ensureAuthenticated} from '../../private/node/session.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param _env - Optional environment variables to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(scopes: string[] = [], _env = process.env): Promise<string> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const envToken = getPartnersToken()\n if (envToken) {\n return (await exchangeCustomPartnerToken(envToken)).accessToken\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}})\n if (!tokens.partners) {\n throw new BugError('No partners token found after ensuring authenticated')\n }\n return tokens.partners\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n forceRefresh = false,\n): Promise<string> {\n if (password) return password\n\n outputDebug(outputContent`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}}, process.env, forceRefresh)\n if (!tokens.storefront) {\n throw new BugError('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${outputToken.raw(\n store,\n )}:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)\n if (!tokens.admin) {\n throw new BugError('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${outputToken.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Ensure that we have a valid session to access the Business Platform API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Business Platform API.\n */\nexport async function ensureAuthenticatedBusinessPlatform(scopes: string[] = []): Promise<string> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Business Platform API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({businessPlatformApi: {scopes}}, process.env)\n if (!tokens.businessPlatform) {\n throw new BugError('No business-platform token found after ensuring authenticated')\n }\n return tokens.businessPlatform\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}
|
package/dist/public/node/ui.d.ts
CHANGED
|
@@ -201,7 +201,7 @@ export interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>,
|
|
|
201
201
|
* Other
|
|
202
202
|
* (f) first
|
|
203
203
|
* (s) second
|
|
204
|
-
* (7) third
|
|
204
|
+
* (7) third (limit reached)
|
|
205
205
|
* (8) fourth
|
|
206
206
|
* (9) seventh
|
|
207
207
|
* (10) tenth
|
|
@@ -257,7 +257,7 @@ export interface RenderAutocompleteOptions<T> extends PartialBy<Omit<Autocomplet
|
|
|
257
257
|
* sixteenth
|
|
258
258
|
* seventeenth
|
|
259
259
|
* eighteenth
|
|
260
|
-
* nineteenth
|
|
260
|
+
* nineteenth (disabled)
|
|
261
261
|
* twentieth
|
|
262
262
|
* twenty-first
|
|
263
263
|
* twenty-second
|
package/dist/public/node/ui.js
CHANGED
|
@@ -218,7 +218,7 @@ export function renderFatalError(error, { renderOptions } = {}) {
|
|
|
218
218
|
* Other
|
|
219
219
|
* (f) first
|
|
220
220
|
* (s) second
|
|
221
|
-
* (7) third
|
|
221
|
+
* (7) third (limit reached)
|
|
222
222
|
* (8) fourth
|
|
223
223
|
* (9) seventh
|
|
224
224
|
* (10) tenth
|
|
@@ -304,7 +304,7 @@ export async function renderConfirmationPrompt({ message, infoTable, confirmatio
|
|
|
304
304
|
* sixteenth
|
|
305
305
|
* seventeenth
|
|
306
306
|
* eighteenth
|
|
307
|
-
* nineteenth
|
|
307
|
+
* nineteenth (disabled)
|
|
308
308
|
* twentieth
|
|
309
309
|
* twenty-first
|
|
310
310
|
* twenty-second
|