@saplings/adapter-app 0.0.0-stage → 0.17.1
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/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -3
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @saplings/adapter-app
|
|
2
|
+
|
|
3
|
+
## 0.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cf8fe00: Prepare the reusable Sapling packages for their first release under the `@saplings` npm scope. Include package license notices and publish installable tarballs with resolved internal dependencies.
|
|
8
|
+
- a94cc08: Update Sharp and Drizzle ORM to patched versions.
|
|
9
|
+
- Updated dependencies [cf8fe00]
|
|
10
|
+
- @saplings/sdk@0.17.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sapling Unified SDK contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { ImageTransformer, OperationsSettings } from '@saplings/sdk';
|
|
3
|
+
export declare class SharpTransformer implements ImageTransformer {
|
|
4
|
+
transform(input: Uint8Array, settings: {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
format: 'webp' | 'png' | 'jpeg';
|
|
8
|
+
}): Promise<Buffer<ArrayBuffer>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function graphqlExecutor(schema: GraphQLSchema, maxDepth?: number, maxNodes?: number): NonNullable<OperationsSettings['graphql']>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
import { graphql, printSchema, parse, visit, validate, specifiedRules, } from 'graphql';
|
|
3
|
+
export class SharpTransformer {
|
|
4
|
+
async transform(input, settings) {
|
|
5
|
+
return sharp(input, { limitInputPixels: 20_000_000, animated: false, failOn: 'error' })
|
|
6
|
+
.rotate()
|
|
7
|
+
.resize(settings.width, settings.height, { fit: 'inside', withoutEnlargement: true })
|
|
8
|
+
.toFormat(settings.format)
|
|
9
|
+
.toBuffer();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function graphqlExecutor(schema, maxDepth = 10, maxNodes = 250) {
|
|
13
|
+
return {
|
|
14
|
+
schema: printSchema(schema),
|
|
15
|
+
async execute(ctx, input) {
|
|
16
|
+
const doc = parse(input.query, { maxTokens: 2000 });
|
|
17
|
+
let depth = 0, nodes = 0;
|
|
18
|
+
visit(doc, {
|
|
19
|
+
Field: {
|
|
20
|
+
enter() {
|
|
21
|
+
if (++depth > maxDepth || ++nodes > maxNodes)
|
|
22
|
+
throw Error('GraphQL complexity limit');
|
|
23
|
+
},
|
|
24
|
+
leave() {
|
|
25
|
+
depth--;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
FragmentSpread() {
|
|
29
|
+
throw Error('Fragments not enabled in bounded executor');
|
|
30
|
+
},
|
|
31
|
+
InlineFragment() {
|
|
32
|
+
throw Error('Fragments not enabled in bounded executor');
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const errors = validate(schema, doc, specifiedRules);
|
|
36
|
+
if (errors.length)
|
|
37
|
+
return { errors: errors.map(() => ({ message: 'Invalid operation' })) };
|
|
38
|
+
const r = await graphql({
|
|
39
|
+
schema,
|
|
40
|
+
source: input.query,
|
|
41
|
+
variableValues: input.variables,
|
|
42
|
+
operationName: input.operationName,
|
|
43
|
+
contextValue: ctx,
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
data: r.data,
|
|
47
|
+
errors: r.errors?.map(() => ({ message: 'GraphQL operation failed' })),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,OAAO,EACP,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,cAAc,GAEf,MAAM,SAAS,CAAC;AAEjB,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAC,SAAS,CACb,KAAiB,EACjB,QAA4E;QAE5E,OAAO,KAAK,CAAC,KAAK,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,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EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAC,EAAE,CAAC;YAC3F,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC;gBACtB,MAAM;gBACN,MAAM,EAAE,KAAK,CAAC,KAAK;gBACnB,cAAc,EAAE,KAAK,CAAC,SAAS;gBAC/B,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,YAAY,EAAE,GAAG;aAClB,CAAC,CAAC;YACH,OAAO;gBACL,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC,CAAC;aACvE,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saplings/adapter-app",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.17.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"graphql": "^16.11.0",
|
|
15
|
+
"sharp": "^0.35.5",
|
|
16
|
+
"@saplings/sdk": "0.17.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^26.0.0"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"CHANGELOG.md"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/snrakshith/saplings.git",
|
|
29
|
+
"directory": "packages/adapter-app"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"registry": "https://registry.npmjs.org/"
|
|
34
|
+
}
|
|
6
35
|
}
|
package/README.md
DELETED