Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move everything out of internal #31

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,31 @@ jobs:
- name: Install dependencies
run: npm install

- name: Compile Plug-in
run: |
cd plugin
npm i
npm run build

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_API_TOKEN }}

- name: Release Plug-in and Schema
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STATIC_S3_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STATIC_S3_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2
run: |
aws s3 cp ${{ github.workspace }}/schema.json s3://static.dylibso.com/schema.json --acl public-read
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on keeping schema.yaml in the repo? if so, I don't see any script that generates schema.json from schema.yaml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also should publish schema-changelog.yml for future use

aws s3 cp ${{ github.workspace }}/plugin/dist/plugin.wasm s3://static.dylibso.com/schema.wasm --acl public-read

- name: Purge Cloudflare Cache
run: |
curl \
-X POST \
-H "Authorization: Bearer ${{ secrets.CF_API_TOKEN }}" \
-d '{"files": ["https://static.dylibso.com/schema.json", "https://static.dylibso.com/schema.wasm"]}' \
https://api.cloudflare.com/client/v4/zones/58f3d5deef300e01c4262266b00fdf4a/purge_cache

16 changes: 8 additions & 8 deletions example-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Learn more at https://docs.xtp.dylibso.com/docs/concepts/xtp-schema
version: v1-draft
exports:
CountVowels:
input:
type: string
contentType: text/plain; charset=utf-8
output:
$ref: "#/components/schemas/VowelReport"
contentType: application/json
countVowels:
input:
type: string
contentType: text/plain; charset=utf-8
output:
$ref: "#/components/schemas/VowelReport"
contentType: application/json
components:
schemas:
VowelReport:
Expand All @@ -25,4 +25,4 @@ components:
nullable: true
vowels:
type: string
description: The set of vowels used to get the count, e.g. "aAeEiIoOuU"
description: The set of vowels used to get the count, e.g. "aAeEiIoOuU"
47 changes: 43 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"esbuild": "^0.17.0",
"esbuild-plugin-d.ts": "^1.2.3",
"jest": "^29.0.0",
"js-yaml": "^4.1.0",
"ts-jest": "^29.0.0",
"typescript": "^5.6.3"
},
Expand All @@ -30,5 +29,12 @@
],
"keywords": [],
"author": "Dylibso, Inc.",
"license": "BSD-3-Clause"
"license": "BSD-3-Clause",
"dependencies": {
"ajv": "^8.17.1",
"js-yaml": "^4.1.0"
},
"overrides": {
"fast-uri": "github:dylibso/fast-uri#remove-unicode-flags-from-regex"
}
}
130 changes: 130 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
4 changes: 4 additions & 0 deletions plugin/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.git

Empty file added plugin/.prettierrc
Empty file.
31 changes: 31 additions & 0 deletions plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# XTP Schema Plugin

The XTP schema plugin is an wrapper around xtp-bindgen. It packages up
some of the functionality of the library into an Extism plugin.

It has 3 exports:

* validate_schema
* get_json_schema
* has_imports

## Usage

Compile:

```
xtp plugin build
```

Run:

```
cat ../example-schema.yaml | xtp plugin call dist/plugin.wasm validate_schema --stdin --wasi | jq

{
"valid": true,
//....
}
```


16 changes: 16 additions & 0 deletions plugin/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const esbuild = require('esbuild');

esbuild
.build({
entryPoints: ['src/index.ts'],
outdir: 'dist',
bundle: true,
sourcemap: true,
minify: false, // might want to use true for production build
format: 'cjs', // needs to be CJS for now
target: ['es2020'], // don't go over es2020 because quickjs doesn't support it
})
.catch((error) => {
console.error('Build failed:', error);
process.exit(1);
});
Loading
Loading