@shopify/shop-minis-cli 0.1.3 → 0.1.5
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/build/commands/submit/submit.js +1 -7
- package/build/commands/submit/submit.js.map +1 -1
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.d.ts +0 -36
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js +0 -5
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js.map +1 -1
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.d.ts +0 -164
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js +0 -282
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js.map +1 -1
- package/build/program.js +0 -4
- package/build/program.js.map +1 -1
- package/build/utils/minis-manifest.d.ts +0 -2
- package/build/utils/minis-manifest.js +0 -8
- package/build/utils/minis-manifest.js.map +1 -1
- package/package.json +1 -1
- package/build/commands/proxies/apply.d.ts +0 -3
- package/build/commands/proxies/apply.js +0 -61
- package/build/commands/proxies/apply.js.map +0 -1
- package/build/commands/proxies/index.d.ts +0 -2
- package/build/commands/proxies/index.js +0 -16
- package/build/commands/proxies/index.js.map +0 -1
- package/build/commands/proxies/list.d.ts +0 -2
- package/build/commands/proxies/list.js +0 -48
- package/build/commands/proxies/list.js.map +0 -1
- package/build/commands/proxies/pull.d.ts +0 -2
- package/build/commands/proxies/pull.js +0 -34
- package/build/commands/proxies/pull.js.map +0 -1
- package/build/commands/secrets/delete.d.ts +0 -2
- package/build/commands/secrets/delete.js +0 -53
- package/build/commands/secrets/delete.js.map +0 -1
- package/build/commands/secrets/index.d.ts +0 -2
- package/build/commands/secrets/index.js +0 -16
- package/build/commands/secrets/index.js.map +0 -1
- package/build/commands/secrets/list.d.ts +0 -2
- package/build/commands/secrets/list.js +0 -29
- package/build/commands/secrets/list.js.map +0 -1
- package/build/commands/secrets/set.d.ts +0 -2
- package/build/commands/secrets/set.js +0 -54
- package/build/commands/secrets/set.js.map +0 -1
- package/build/data/proxies/proxies-list.d.ts +0 -9
- package/build/data/proxies/proxies-list.js +0 -19
- package/build/data/proxies/proxies-list.js.map +0 -1
- package/build/data/proxies/proxies-set.d.ts +0 -5
- package/build/data/proxies/proxies-set.js +0 -22
- package/build/data/proxies/proxies-set.js.map +0 -1
- package/build/data/proxies/types.d.ts +0 -10
- package/build/data/proxies/types.js +0 -2
- package/build/data/proxies/types.js.map +0 -1
- package/build/data/secrets/secret-delete.d.ts +0 -12
- package/build/data/secrets/secret-delete.js +0 -20
- package/build/data/secrets/secret-delete.js.map +0 -1
- package/build/data/secrets/secret-set.d.ts +0 -11
- package/build/data/secrets/secret-set.js +0 -19
- package/build/data/secrets/secret-set.js.map +0 -1
- package/build/data/secrets/secrets-list.d.ts +0 -8
- package/build/data/secrets/secrets-list.js +0 -14
- package/build/data/secrets/secrets-list.js.map +0 -1
- package/build/utils/proxies.d.ts +0 -13
- package/build/utils/proxies.js +0 -105
- package/build/utils/proxies.js.map +0 -1
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { renderError, renderSuccess } from '@shopify/cli-kit/node/ui';
|
|
3
|
-
import { handler as handleError } from '@shopify/cli-kit/node/error';
|
|
4
|
-
import { secretSet } from '../../data/secrets/secret-set.js';
|
|
5
|
-
import { assertNetworkAndAuth } from '../../utils/common-tasks.js';
|
|
6
|
-
import { getRunBinCommand } from '../../utils/package-manager.js';
|
|
7
|
-
export const command = new Command()
|
|
8
|
-
.name('set')
|
|
9
|
-
.description('Set a secret to be used in a proxy configuration.')
|
|
10
|
-
.argument('<secret key>', 'The key of the secret to set.')
|
|
11
|
-
.argument('<secret value>', 'The value of the secret to set.')
|
|
12
|
-
.action(async (secretKeyArg, secretValueArg) => {
|
|
13
|
-
try {
|
|
14
|
-
if (!secretKeyArg || !secretValueArg) {
|
|
15
|
-
const exampleCommand = await getRunBinCommand('shop-minis secrets set my-secret-key my-secret-value');
|
|
16
|
-
renderError({
|
|
17
|
-
headline: 'Missing secret key or value',
|
|
18
|
-
body: [
|
|
19
|
-
'Please provide both a secret key and value.',
|
|
20
|
-
`Example: ${exampleCommand}`,
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
await assertNetworkAndAuth();
|
|
26
|
-
const { secret } = await secretSet({
|
|
27
|
-
key: secretKeyArg,
|
|
28
|
-
value: secretValueArg,
|
|
29
|
-
});
|
|
30
|
-
if (secret) {
|
|
31
|
-
renderSuccess({
|
|
32
|
-
headline: 'Secret set',
|
|
33
|
-
body: [
|
|
34
|
-
'Secret key',
|
|
35
|
-
{
|
|
36
|
-
bold: secret.key,
|
|
37
|
-
},
|
|
38
|
-
'has been set for your Shop Mini.',
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
renderError({
|
|
44
|
-
headline: 'Error setting secret',
|
|
45
|
-
body: 'Please try again.',
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
handleError(error);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/commands/secrets/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAA;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAA;AAE/D,MAAM,CAAC,M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?: import("../types/autogenerated/shop-minis-admin-api/graphql.js").HttpRequestMethod[] | null | undefined;
|
|
4
|
-
appendedHeaders?: string[] | null | undefined;
|
|
5
|
-
bodyJsonSchema?: any;
|
|
6
|
-
targetUrlPattern: string;
|
|
7
|
-
userRateLimitInterval?: number | null | undefined;
|
|
8
|
-
userRateLimitRequests?: number | null | undefined;
|
|
9
|
-
}[]>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { graphql } from '../types/autogenerated/shop-minis-admin-api/gql.js';
|
|
2
|
-
import { client } from '../gql-client.js';
|
|
3
|
-
const proxiesQuery = graphql(/* GraphQL */ `
|
|
4
|
-
query Proxies {
|
|
5
|
-
proxies {
|
|
6
|
-
allowedMethods
|
|
7
|
-
appendedHeaders
|
|
8
|
-
bodyJsonSchema
|
|
9
|
-
targetUrlPattern
|
|
10
|
-
userRateLimitInterval
|
|
11
|
-
userRateLimitRequests
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
`);
|
|
15
|
-
export const proxiesList = async () => {
|
|
16
|
-
const data = await client.request(proxiesQuery);
|
|
17
|
-
return data.proxies;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=proxies-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxies-list.js","sourceRoot":"","sources":["../../../src/data/proxies/proxies-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oDAAoD,CAAA;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;CAW1C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;IACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAE/C,OAAO,IAAI,CAAC,OAAO,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ProxyInput } from '../types/autogenerated/shop-minis-admin-api/graphql.js';
|
|
2
|
-
export interface ProxiesSetParameters {
|
|
3
|
-
proxies: ProxyInput[];
|
|
4
|
-
}
|
|
5
|
-
export declare const proxiesSet: ({ proxies }: ProxiesSetParameters) => Promise<import("../types/autogenerated/shop-minis-admin-api/graphql.js").ProxiesSetMutation>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { graphql } from '../types/autogenerated/shop-minis-admin-api/gql.js';
|
|
2
|
-
import { client } from '../gql-client.js';
|
|
3
|
-
const proxiesSetQuery = graphql(/* GraphQL */ `
|
|
4
|
-
mutation ProxiesSet($proxies: [ProxyInput!]!) {
|
|
5
|
-
proxiesSet(proxies: $proxies) {
|
|
6
|
-
proxies {
|
|
7
|
-
targetUrlPattern
|
|
8
|
-
}
|
|
9
|
-
userErrors {
|
|
10
|
-
code
|
|
11
|
-
message
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`);
|
|
16
|
-
export const proxiesSet = async ({ proxies }) => {
|
|
17
|
-
const data = await client.request(proxiesSetQuery, {
|
|
18
|
-
proxies,
|
|
19
|
-
});
|
|
20
|
-
return data;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=proxies-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxies-set.js","sourceRoot":"","sources":["../../../src/data/proxies/proxies-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oDAAoD,CAAA;AAE1E,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;;;CAY7C,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAC,OAAO,EAAuB,EAAE,EAAE;IAClE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE;QACjD,OAAO;KACR,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Proxy, HttpRequestMethod } from '../types/autogenerated/shop-minis-admin-api/graphql.js';
|
|
2
|
-
export type RemoteProxy = Proxy;
|
|
3
|
-
export interface ManifestProxy {
|
|
4
|
-
target_url_pattern: string;
|
|
5
|
-
allowed_methods?: HttpRequestMethod[];
|
|
6
|
-
appended_headers?: string[];
|
|
7
|
-
body_json_schema?: any;
|
|
8
|
-
user_rate_limit_interval?: number;
|
|
9
|
-
user_rate_limit_requests?: number;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/data/proxies/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface SecretSetParameters {
|
|
2
|
-
key: string;
|
|
3
|
-
}
|
|
4
|
-
export declare const secretDelete: ({ key }: SecretSetParameters) => Promise<{
|
|
5
|
-
__typename?: "SecretDeletePayload" | undefined;
|
|
6
|
-
userErrors: {
|
|
7
|
-
__typename?: "SecretDeleteUserError" | undefined;
|
|
8
|
-
code: import("../types/autogenerated/shop-minis-admin-api/graphql.js").SecretDeleteUserErrorCode;
|
|
9
|
-
field?: string[] | null | undefined;
|
|
10
|
-
message: string;
|
|
11
|
-
}[];
|
|
12
|
-
}>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { graphql } from '../types/autogenerated/shop-minis-admin-api/gql.js';
|
|
2
|
-
import { client } from '../gql-client.js';
|
|
3
|
-
const secretDeleteQuery = graphql(/* GraphQL */ `
|
|
4
|
-
mutation SecretDelete($key: String!) {
|
|
5
|
-
secretDelete(key: $key) {
|
|
6
|
-
userErrors {
|
|
7
|
-
code
|
|
8
|
-
field
|
|
9
|
-
message
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`);
|
|
14
|
-
export const secretDelete = async ({ key }) => {
|
|
15
|
-
const data = await client.request(secretDeleteQuery, {
|
|
16
|
-
key,
|
|
17
|
-
});
|
|
18
|
-
return data.secretDelete;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=secret-delete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secret-delete.js","sourceRoot":"","sources":["../../../src/data/secrets/secret-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oDAAoD,CAAA;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;;;;;;;;;;CAU/C,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EAAC,GAAG,EAAsB,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE;QACnD,GAAG;KACJ,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,YAAY,CAAA;AAC1B,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface SecretSetParameters {
|
|
2
|
-
key: string;
|
|
3
|
-
value: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const secretSet: ({ key, value }: SecretSetParameters) => Promise<{
|
|
6
|
-
__typename?: "SecretSetPayload" | undefined;
|
|
7
|
-
secret?: {
|
|
8
|
-
__typename?: "Secret" | undefined;
|
|
9
|
-
key: string;
|
|
10
|
-
} | null | undefined;
|
|
11
|
-
}>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { graphql } from '../types/autogenerated/shop-minis-admin-api/gql.js';
|
|
2
|
-
import { client } from '../gql-client.js';
|
|
3
|
-
const secretSetQuery = graphql(/* GraphQL */ `
|
|
4
|
-
mutation SecretSet($key: String!, $secretValue: String!) {
|
|
5
|
-
secretSet(key: $key, value: $secretValue) {
|
|
6
|
-
secret {
|
|
7
|
-
key
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`);
|
|
12
|
-
export const secretSet = async ({ key, value }) => {
|
|
13
|
-
const data = await client.request(secretSetQuery, {
|
|
14
|
-
key,
|
|
15
|
-
secretValue: value,
|
|
16
|
-
});
|
|
17
|
-
return data.secretSet;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=secret-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secret-set.js","sourceRoot":"","sources":["../../../src/data/secrets/secret-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oDAAoD,CAAA;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;;;;;;;;CAQ5C,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,EAAC,GAAG,EAAE,KAAK,EAAsB,EAAE,EAAE;IACnE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE;QAChD,GAAG;QACH,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,SAAS,CAAA;AACvB,CAAC,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { graphql } from '../types/autogenerated/shop-minis-admin-api/gql.js';
|
|
2
|
-
import { client } from '../gql-client.js';
|
|
3
|
-
const secretsQuery = graphql(/* GraphQL */ `
|
|
4
|
-
query Secrets {
|
|
5
|
-
secrets {
|
|
6
|
-
key
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
`);
|
|
10
|
-
export const secretsList = async () => {
|
|
11
|
-
const data = await client.request(secretsQuery);
|
|
12
|
-
return data.secrets;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=secrets-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets-list.js","sourceRoot":"","sources":["../../../src/data/secrets/secrets-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,oDAAoD,CAAA;AAC1E,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;;;;;;CAM1C,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;IACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAE/C,OAAO,IAAI,CAAC,OAAO,CAAA;AACrB,CAAC,CAAA"}
|
package/build/utils/proxies.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Change } from 'diff';
|
|
2
|
-
import type { RemoteProxy, ManifestProxy } from '../data/proxies/types.js';
|
|
3
|
-
import { HttpRequestMethod } from '../data/types/autogenerated/shop-minis-admin-api/graphql.js';
|
|
4
|
-
export declare const remoteProxyToManifestProxy: (proxy: RemoteProxy) => ManifestProxy;
|
|
5
|
-
export declare const remoteProxiesToManifestProxies: (remoteProxies: RemoteProxy[]) => ManifestProxy[];
|
|
6
|
-
export declare const manifestProxyToRemoteProxy: (proxy: ManifestProxy) => RemoteProxy;
|
|
7
|
-
export declare const manifestProxiesToRemoteProxies: (manifestProxies: ManifestProxy[]) => RemoteProxy[];
|
|
8
|
-
export declare const allowedMethodsMap: Record<string, HttpRequestMethod>;
|
|
9
|
-
export declare const proxiesDiff: (remoteProxies: ManifestProxy[], localProxies: ManifestProxy[]) => {
|
|
10
|
-
changes: Change[];
|
|
11
|
-
string: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const getLocalProxies: () => ManifestProxy[];
|
package/build/utils/proxies.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import colors from '@shopify/cli-kit/node/colors';
|
|
2
|
-
import { diffLines } from 'diff';
|
|
3
|
-
import { HttpRequestMethod } from '../data/types/autogenerated/shop-minis-admin-api/graphql.js';
|
|
4
|
-
import { getMiniManifest } from './minis-manifest.js';
|
|
5
|
-
// Convert the remote proxy to the manifest proxy format
|
|
6
|
-
// We don't set null values because they are the default and make the diffs larger than they need to be
|
|
7
|
-
export const remoteProxyToManifestProxy = proxy => {
|
|
8
|
-
// Required fields
|
|
9
|
-
const manifestProxy = {
|
|
10
|
-
target_url_pattern: proxy.targetUrlPattern,
|
|
11
|
-
};
|
|
12
|
-
// Optional fields, we only set them if they are meaningfully different from the defaults
|
|
13
|
-
if (proxy.allowedMethods !== null) {
|
|
14
|
-
manifestProxy.allowed_methods = proxy.allowedMethods;
|
|
15
|
-
}
|
|
16
|
-
if (proxy.appendedHeaders !== null) {
|
|
17
|
-
manifestProxy.appended_headers = proxy.appendedHeaders;
|
|
18
|
-
}
|
|
19
|
-
if (proxy.bodyJsonSchema !== null) {
|
|
20
|
-
manifestProxy.body_json_schema = proxy.bodyJsonSchema;
|
|
21
|
-
}
|
|
22
|
-
if (typeof proxy.userRateLimitInterval === 'number') {
|
|
23
|
-
manifestProxy.user_rate_limit_interval = proxy.userRateLimitInterval;
|
|
24
|
-
}
|
|
25
|
-
if (typeof proxy.userRateLimitRequests === 'number') {
|
|
26
|
-
manifestProxy.user_rate_limit_requests = proxy.userRateLimitRequests;
|
|
27
|
-
}
|
|
28
|
-
return manifestProxy;
|
|
29
|
-
};
|
|
30
|
-
export const remoteProxiesToManifestProxies = remoteProxies => {
|
|
31
|
-
return remoteProxies.map(remoteProxyToManifestProxy);
|
|
32
|
-
};
|
|
33
|
-
// Convert the manifest proxy to the remote proxy format
|
|
34
|
-
export const manifestProxyToRemoteProxy = proxy => {
|
|
35
|
-
const remoteProxy = {
|
|
36
|
-
targetUrlPattern: proxy.target_url_pattern,
|
|
37
|
-
allowedMethods: proxy.allowed_methods,
|
|
38
|
-
appendedHeaders: proxy.appended_headers,
|
|
39
|
-
bodyJsonSchema: proxy.body_json_schema,
|
|
40
|
-
userRateLimitInterval: proxy.user_rate_limit_interval,
|
|
41
|
-
userRateLimitRequests: proxy.user_rate_limit_requests,
|
|
42
|
-
};
|
|
43
|
-
return remoteProxy;
|
|
44
|
-
};
|
|
45
|
-
export const manifestProxiesToRemoteProxies = manifestProxies => {
|
|
46
|
-
return manifestProxies.map(manifestProxyToRemoteProxy);
|
|
47
|
-
};
|
|
48
|
-
export const allowedMethodsMap = {
|
|
49
|
-
GET: HttpRequestMethod.Get,
|
|
50
|
-
POST: HttpRequestMethod.Post,
|
|
51
|
-
PUT: HttpRequestMethod.Put,
|
|
52
|
-
DELETE: HttpRequestMethod.Delete,
|
|
53
|
-
PATCH: HttpRequestMethod.Patch,
|
|
54
|
-
};
|
|
55
|
-
const lines = (value) => {
|
|
56
|
-
return value.split(/\n/).filter(line => line !== '');
|
|
57
|
-
};
|
|
58
|
-
// Copied to modify from cli-kit
|
|
59
|
-
// https://github.com/Shopify/cli/blob/5dc24c6126d727c4384a35ab32f2ef7104d06556/packages/cli-kit/src/private/node/content-tokens.ts#L60
|
|
60
|
-
const diffString = (value) => {
|
|
61
|
-
return value
|
|
62
|
-
.map(part => {
|
|
63
|
-
if (part.added) {
|
|
64
|
-
return lines(part.value).map(line => {
|
|
65
|
-
return colors.green(`+ ${line}\n`);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (part.removed) {
|
|
69
|
-
return lines(part.value).map(line => {
|
|
70
|
-
return colors.magenta(`- ${line}\n`);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return lines(part.value).map(line => {
|
|
75
|
-
return ` ${line}\n`;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
.flat()
|
|
80
|
-
.join('');
|
|
81
|
-
};
|
|
82
|
-
export const proxiesDiff = (remoteProxies, localProxies) => {
|
|
83
|
-
const diff = diffLines(JSON.stringify(remoteProxies, null, 2), JSON.stringify(localProxies, null, 2));
|
|
84
|
-
return {
|
|
85
|
-
changes: diff,
|
|
86
|
-
string: diffString(diff),
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
export const getLocalProxies = () => {
|
|
90
|
-
const manifest = getMiniManifest();
|
|
91
|
-
const defaultLocalProxies = [];
|
|
92
|
-
const localProxies = manifest?.proxies?.map((proxy) => {
|
|
93
|
-
const manifestProxy = {
|
|
94
|
-
target_url_pattern: proxy.target_url_pattern,
|
|
95
|
-
allowed_methods: proxy.allowed_methods?.map(allowedMethod => allowedMethodsMap[allowedMethod]),
|
|
96
|
-
appended_headers: proxy.appended_headers,
|
|
97
|
-
body_json_schema: proxy.body_json_schema,
|
|
98
|
-
user_rate_limit_interval: proxy.user_rate_limit_interval,
|
|
99
|
-
user_rate_limit_requests: proxy.user_rate_limit_requests,
|
|
100
|
-
};
|
|
101
|
-
return manifestProxy;
|
|
102
|
-
}) ?? defaultLocalProxies;
|
|
103
|
-
return localProxies;
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=proxies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxies.js","sourceRoot":"","sources":["../../src/utils/proxies.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,8BAA8B,CAAA;AACjD,OAAO,EAAS,SAAS,EAAC,MAAM,MAAM,CAAA;AAGtC,OAAO,EAAC,iBAAiB,EAAC,MAAM,6DAA6D,CAAA;AAE7F,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAA;AAEnD,wDAAwD;AACxD,uGAAuG;AACvG,MAAM,CAAC,MAAM,0BAA0B,GAElB,KAAK,CAAC,EAAE;IAC3B,kBAAkB;IAClB,MAAM,aAAa,GAAkB;QACnC,kBAAkB,EAAE,KAAK,CAAC,gBAAgB;KAC3C,CAAA;IAED,yFAAyF;IAEzF,IAAI,KAAK,CAAC,cAAc,KAAK,I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