@contrail/cli 3.6.0-alpha-7-alpha.d8f5a20 → 3.6.0-alpha-8-alpha.668a0d5
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/README.md +1 -1
- package/dist/commands/entities/delete.js +2 -16
- package/dist/commands/entities/get.js +2 -1
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/pull_request_template.md +31 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/check-code-formatting.yml +34 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/empty.yml +10 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/generate-sdk-docs.yml +32 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +117 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/sdk-lib.yml +27 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.prettierrc.yaml +2 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/README.md +72 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/home-hero.svg +11 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.d.ts +9 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.js +54 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.d.ts +10 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.js +6 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.d.ts +2 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.js +18 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.d.ts +10 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.js +209 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.d.ts +48 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.js +42 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.d.ts +12 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.js +70 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.d.ts +15 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.js +241 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +101 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.js +306 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.d.ts +9 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.js +86 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.d.ts +6 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.js +19 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.d.ts +5 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +59 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.d.ts +3 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.js +19 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.d.ts +3 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.js +24 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.d.ts +19 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.js +151 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +10 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +26 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.d.ts +16 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.js +37 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.d.ts +1 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.js +17 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.d.ts +12 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.js +55 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.d.ts +9 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.js +74 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.d.ts +2 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.js +18 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.d.ts +18 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.js +98 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.d.ts +19 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.js +73 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.d.ts +42 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.js +217 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +64 -0
- package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/scripts/replicate-bug.js +69 -0
- package/node_modules/@contrail/sdk/lib/core/request.js +6 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +2 -0
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +2 -0
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.6.0-alpha-
|
|
20
|
+
@contrail/cli/3.6.0-alpha-8-alpha.668a0d5 linux-x64 node-v24.20.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -98,21 +98,7 @@ async function deleteEntityByIds(entityName, ids) {
|
|
|
98
98
|
async function deleteEntityById(entityName, id) {
|
|
99
99
|
const client = new sdk_1.Entities();
|
|
100
100
|
if (IS_DRY_RUN) {
|
|
101
|
-
return client.get({ entityName, id })
|
|
101
|
+
return client.get({ entityName, id, ignore404: true });
|
|
102
102
|
}
|
|
103
|
-
return client.delete({ entityName, id })
|
|
104
|
-
}
|
|
105
|
-
function throwIfNot404(e) {
|
|
106
|
-
const { statusCode } = parseSDKErrorMessage(e);
|
|
107
|
-
if (statusCode === 404) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
throw e;
|
|
111
|
-
}
|
|
112
|
-
function parseSDKErrorMessage(e) {
|
|
113
|
-
const parsed = JSON.parse(e.details);
|
|
114
|
-
return {
|
|
115
|
-
statusCode: parsed.statusCode,
|
|
116
|
-
message: parsed.message,
|
|
117
|
-
};
|
|
103
|
+
return client.delete({ entityName, id, ignore404: true });
|
|
118
104
|
}
|
|
@@ -183,7 +183,8 @@ async function find(entityName, options = {}) {
|
|
|
183
183
|
return (0, batchFetch_1.batchFetch)(entityName, payload);
|
|
184
184
|
}
|
|
185
185
|
else {
|
|
186
|
-
return
|
|
186
|
+
// Fetching by id can 404; return null for a missing entity instead of retrying and throwing
|
|
187
|
+
return client.get(id ? { ...payload, ignore404: true } : payload);
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
async function* streamPaginatedFind(typePath, options = {}) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## What
|
|
2
|
+
|
|
3
|
+
- [ ] Bugfix
|
|
4
|
+
- [ ] Feature
|
|
5
|
+
- [ ] Enhancement
|
|
6
|
+
|
|
7
|
+
Description:
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Describe the functional changes of the PR.
|
|
11
|
+
|
|
12
|
+
If the mechanism of your change are complex, describe them in detail as you
|
|
13
|
+
would if you were explaining them to a team mate.
|
|
14
|
+
|
|
15
|
+
If the PR is simple, there is no need to repeat yourself. A small description
|
|
16
|
+
is sufficient.
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
why is this change needed? Same rules as with #What
|
|
23
|
+
-->
|
|
24
|
+
|
|
25
|
+
## Testing added
|
|
26
|
+
|
|
27
|
+
<!--
|
|
28
|
+
Describe the testing you added to this PR
|
|
29
|
+
-->
|
|
30
|
+
|
|
31
|
+
## Link to Jira ticket(s)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Check Code Formatting
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
paths:
|
|
5
|
+
- '**'
|
|
6
|
+
workflow_dispatch: # allow running in github actions manually
|
|
7
|
+
jobs:
|
|
8
|
+
check-formatting:
|
|
9
|
+
runs-on: ubuntu-24.04
|
|
10
|
+
steps:
|
|
11
|
+
- name: Node.js
|
|
12
|
+
uses: actions/setup-node@v3
|
|
13
|
+
with:
|
|
14
|
+
node-version: 20
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
with:
|
|
17
|
+
lfs: true
|
|
18
|
+
- name: Checkout LFS objects
|
|
19
|
+
run: git lfs checkout
|
|
20
|
+
- name: NPM Install
|
|
21
|
+
env:
|
|
22
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
23
|
+
run: npm ci
|
|
24
|
+
- name: Check Format
|
|
25
|
+
working-directory: ./
|
|
26
|
+
run: npx prettier --check .
|
|
27
|
+
- name: Fail On Warnings
|
|
28
|
+
run: |
|
|
29
|
+
if [ $? -eq 0 ]; then
|
|
30
|
+
echo "No formatting issues found"
|
|
31
|
+
else
|
|
32
|
+
echo "Formatting issues found. Run 'npx prettier --write .' to fix them."
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: generate-sdk-docs
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
paths:
|
|
7
|
+
- '**'
|
|
8
|
+
workflow_dispatch: # allow running in github actions manually
|
|
9
|
+
jobs:
|
|
10
|
+
deploy-docs:
|
|
11
|
+
runs-on: ubuntu-24.04
|
|
12
|
+
steps:
|
|
13
|
+
- name: Node.js
|
|
14
|
+
uses: actions/setup-node@v3
|
|
15
|
+
with:
|
|
16
|
+
node-version: 16.17.0
|
|
17
|
+
|
|
18
|
+
- uses: actions/checkout@v3
|
|
19
|
+
|
|
20
|
+
- name: NPM Install
|
|
21
|
+
env:
|
|
22
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
23
|
+
run: npm ci
|
|
24
|
+
- name: Build SDK Docs
|
|
25
|
+
env:
|
|
26
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
27
|
+
run: npm run generate-docs
|
|
28
|
+
- name: Deploy 🚀
|
|
29
|
+
uses: JamesIves/github-pages-deploy-action@4.1.4
|
|
30
|
+
with:
|
|
31
|
+
branch: gh-pages
|
|
32
|
+
folder: docs
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
name: Publish to NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ['**']
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check-version:
|
|
11
|
+
name: Verify version is available on npm
|
|
12
|
+
if: github.event_name == 'pull_request'
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Check version not already published
|
|
18
|
+
run: |
|
|
19
|
+
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
20
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
21
|
+
echo "Checking if ${PACKAGE_NAME}@${VERSION} exists on npm..."
|
|
22
|
+
if npm view "${PACKAGE_NAME}@${VERSION}" version 2>/dev/null; then
|
|
23
|
+
echo "::error::Version ${VERSION} is already published on npm. Bump the version in package.json before merging."
|
|
24
|
+
exit 1
|
|
25
|
+
else
|
|
26
|
+
echo "Version ${VERSION} is available."
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
check-dependencies:
|
|
30
|
+
name: Verify no private dependencies
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- name: Verify no private dependencies
|
|
36
|
+
run: |
|
|
37
|
+
node -e "
|
|
38
|
+
const deps = require('./package.json').dependencies || {};
|
|
39
|
+
const { execSync } = require('child_process');
|
|
40
|
+
let failed = false;
|
|
41
|
+
for (const pkg of Object.keys(deps)) {
|
|
42
|
+
try {
|
|
43
|
+
execSync('npm view ' + pkg, { stdio: 'pipe' });
|
|
44
|
+
} catch {
|
|
45
|
+
console.error('::error::Dependency ' + pkg + ' is not publicly accessible on npm');
|
|
46
|
+
failed = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (failed) process.exit(1);
|
|
50
|
+
console.log('All ' + Object.keys(deps).length + ' dependencies are public.');
|
|
51
|
+
"
|
|
52
|
+
|
|
53
|
+
publish-alpha:
|
|
54
|
+
name: Publish alpha
|
|
55
|
+
needs: check-dependencies
|
|
56
|
+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
permissions:
|
|
59
|
+
id-token: write
|
|
60
|
+
contents: read
|
|
61
|
+
outputs:
|
|
62
|
+
version: ${{ steps.publish.outputs.version }}
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v4
|
|
65
|
+
|
|
66
|
+
- uses: actions/setup-node@v4
|
|
67
|
+
with:
|
|
68
|
+
node-version: '24'
|
|
69
|
+
registry-url: 'https://registry.npmjs.org'
|
|
70
|
+
|
|
71
|
+
- name: Install and build
|
|
72
|
+
run: npm ci && npm run build
|
|
73
|
+
|
|
74
|
+
- name: Publish alpha
|
|
75
|
+
id: publish
|
|
76
|
+
run: |
|
|
77
|
+
SHORT_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)
|
|
78
|
+
VERSION=$(node -p "require('./package.json').version")-alpha.${SHORT_SHA}
|
|
79
|
+
npm version $VERSION --no-git-tag-version
|
|
80
|
+
OUTPUT=$(npm publish --tag alpha 2>&1) && {
|
|
81
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
82
|
+
} || {
|
|
83
|
+
if echo "$OUTPUT" | grep -q "You cannot publish over the previously published versions"; then
|
|
84
|
+
echo "::warning::Alpha ${VERSION} already published, skipping."
|
|
85
|
+
else
|
|
86
|
+
echo "::error::Failed to publish alpha ${VERSION}"
|
|
87
|
+
echo "$OUTPUT"
|
|
88
|
+
exit 1
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
publish-release:
|
|
93
|
+
name: Publish release
|
|
94
|
+
needs: check-dependencies
|
|
95
|
+
if: github.event_name == 'push'
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
permissions:
|
|
98
|
+
id-token: write
|
|
99
|
+
contents: read
|
|
100
|
+
outputs:
|
|
101
|
+
version: ${{ steps.publish.outputs.version }}
|
|
102
|
+
steps:
|
|
103
|
+
- uses: actions/checkout@v4
|
|
104
|
+
|
|
105
|
+
- uses: actions/setup-node@v4
|
|
106
|
+
with:
|
|
107
|
+
node-version: '24'
|
|
108
|
+
registry-url: 'https://registry.npmjs.org'
|
|
109
|
+
|
|
110
|
+
- name: Install and build
|
|
111
|
+
run: npm ci && npm run build
|
|
112
|
+
|
|
113
|
+
- name: Publish release
|
|
114
|
+
id: publish
|
|
115
|
+
run: |
|
|
116
|
+
npm publish
|
|
117
|
+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: sdk-lib-tests
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
# run this workflow when files these files change
|
|
5
|
+
paths:
|
|
6
|
+
- '**'
|
|
7
|
+
workflow_dispatch: # allow running in github actions manually
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-24.04
|
|
11
|
+
steps:
|
|
12
|
+
- name: Node.js
|
|
13
|
+
uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: ${{ matrix.node-version }}
|
|
16
|
+
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- name: NPM Install
|
|
20
|
+
env:
|
|
21
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
22
|
+
run: npm ci
|
|
23
|
+
|
|
24
|
+
- name: Unit Tests -
|
|
25
|
+
env:
|
|
26
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
27
|
+
run: npm test
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# [Contrail SDK](https://archergreysorg.github.io/contrail-lib/)
|
|
2
|
+
|
|
3
|
+
Functionality within the VibeIQ platform (Contrail) can be accessed and extended through a TypeScript SDK. The SDK is installable via the popular JavaScript Node Packages Manager `npm`.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @contrail/sdk --global
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This will install the contrail SDK globally to your system, which will enable you to use it in any script, regardless of which directory it is in.
|
|
10
|
+
|
|
11
|
+
Alternatively, If you are using the SDK as part of a module you plan on packaging and sharing with other developers (or deploying to the cloud), you can add the SDK to your project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @contrail/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Scripting vs App development
|
|
18
|
+
|
|
19
|
+
In the world of Javascript, code can be written as a one-off "script", run through the `node` interpreter, or packaged as part of an application. Below are examples on how to authenticate and print your username in each of these paradigms.
|
|
20
|
+
|
|
21
|
+
#### Scripting
|
|
22
|
+
|
|
23
|
+
To use the Contrail SDK as part of a one-off script, you can use the `require` javascript keyword.
|
|
24
|
+
|
|
25
|
+
```js title="script.js"
|
|
26
|
+
const contrail = require('@contrail/sdk');
|
|
27
|
+
|
|
28
|
+
// define an asynchronous function
|
|
29
|
+
const run = async () => {
|
|
30
|
+
await contrail.login({ orgSlug: 'YOUR-ORG-HERE', email: 'myEmail@example.com', password: 'neverInPlainText' });
|
|
31
|
+
|
|
32
|
+
// or using an api key like the one you can get from `contrail app getApiKey`
|
|
33
|
+
// await contrail.login({orgSlug: 'test-zone-1', apiKey: 'app:qwerty'})
|
|
34
|
+
|
|
35
|
+
const user = await contrail.getCurrentUser();
|
|
36
|
+
console.log('USER:', JSON.stringify(user, null, 2));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// run the function
|
|
40
|
+
run();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can run your script using `node` in your shell.
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
node script.js
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Packaged Module
|
|
50
|
+
|
|
51
|
+
If you intend on using the Contrail SDK as part of your packaging module, you may use the `import` keyword. You are more likely to use this when writing integrations as part of a web or server runtime.
|
|
52
|
+
|
|
53
|
+
```js title="someServerFile.js"
|
|
54
|
+
import { login, getCurrentUser } from '@contrail/sdk';
|
|
55
|
+
|
|
56
|
+
export async function run() {
|
|
57
|
+
await login({ orgSlug: 'YOUR-ORG-HERE', email: 'myEmail@example.com', password: 'neverInPlainText' });
|
|
58
|
+
|
|
59
|
+
// or using an api key like the one you can get from `contrail app getApiKey`
|
|
60
|
+
// await login({orgSlug: 'test-zone-1', apiKey: 'app:qwerty'})
|
|
61
|
+
|
|
62
|
+
const user = await getCurrentUser();
|
|
63
|
+
console.log('USER:', JSON.stringify(user, null, 2));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// run the function
|
|
67
|
+
run();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
# General Documentation
|
|
71
|
+
|
|
72
|
+
Complete documentation for the VibeIQ platform lives on [https://docs.vibeiq.com/](https://docs.vibeiq.com/).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="635" height="433" viewBox="0 0 635 433" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_309_15692)">
|
|
3
|
+
<path d="M656.604 384.076C457.662 384.076 414.538 48.9114 216.574 48.9114C172.144 48.9339 129.54 66.5999 98.1308 98.0252C66.7213 129.451 49.077 172.063 49.077 216.494" stroke="#202532" stroke-width="97.8221" stroke-miterlimit="10"/>
|
|
4
|
+
<path d="M49.077 216.494C49.077 309.04 128.454 384.076 216.66 384.076C415.601 384.076 457.747 48.9114 656.689 48.9114C701.134 48.9114 743.76 66.5673 775.188 97.9952C806.615 129.423 824.272 172.048 824.272 216.494C824.272 260.94 806.615 303.565 775.188 334.993C743.76 366.421 701.134 384.076 656.689 384.076" stroke="#00ABE9" stroke-width="97.8221" stroke-miterlimit="10"/>
|
|
5
|
+
</g>
|
|
6
|
+
<defs>
|
|
7
|
+
<clipPath id="clip0_309_15692">
|
|
8
|
+
<rect width="873.016" height="432.987" fill="white" transform="translate(0.166809)"/>
|
|
9
|
+
</clipPath>
|
|
10
|
+
</defs>
|
|
11
|
+
</svg>
|
package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Assets = void 0;
|
|
13
|
+
const entities_1 = require("../entities");
|
|
14
|
+
const file_type_helper_1 = require("../files/file-type-helper");
|
|
15
|
+
const files_1 = require("../files/files");
|
|
16
|
+
class Assets {
|
|
17
|
+
create(options) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
let asset = null;
|
|
20
|
+
if (options.file) {
|
|
21
|
+
const file = options.file;
|
|
22
|
+
if (!file) {
|
|
23
|
+
throw Error(`Must specify file in create.`);
|
|
24
|
+
}
|
|
25
|
+
const contentType = file.type || file_type_helper_1.FileTypeHelper.getContentType(file);
|
|
26
|
+
asset = yield new entities_1.Entities().create({
|
|
27
|
+
entityName: 'asset',
|
|
28
|
+
object: {
|
|
29
|
+
contentHolderReference: options.contentHolderReference,
|
|
30
|
+
fileName: file.name,
|
|
31
|
+
contentType,
|
|
32
|
+
workspaceId: options.workspaceId,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
yield new files_1.Files().uploadFile(asset.content.primaryFile.uploadPost, file);
|
|
36
|
+
}
|
|
37
|
+
else if (options.fileId) {
|
|
38
|
+
asset = yield new entities_1.Entities().create({
|
|
39
|
+
entityName: 'asset',
|
|
40
|
+
object: {
|
|
41
|
+
contentHolderReference: options.contentHolderReference,
|
|
42
|
+
copyFileId: options.fileId,
|
|
43
|
+
workspaceId: options.workspaceId,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error('Must specify file or fileId');
|
|
49
|
+
}
|
|
50
|
+
return asset;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Assets = Assets;
|
package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './assets';
|
package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./assets"), exports);
|
package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./login"), exports);
|
|
18
|
+
__exportStar(require("./auth"), exports);
|
package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthContext } from './auth';
|
|
2
|
+
export interface LoginCredentials {
|
|
3
|
+
orgSlug: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
password?: string;
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function setAppCredentials(apiKey: string, orgSlug: string): Promise<AuthContext>;
|
|
9
|
+
export declare function login(credentials: LoginCredentials): Promise<AuthContext>;
|
|
10
|
+
export declare function getCurrentUser(): Promise<any>;
|