@snappy-stack/sdk 0.1.4

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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ SNAPPY SDK โ€” Proprietary License
2
+ Copyright (c) 2026 Wicky.ID โ€” Kaiser Wicky
3
+
4
+ This software is proprietary and confidential.
5
+ Unauthorized copying, modification, distribution, or use
6
+ of this software, in source or binary form, is strictly
7
+ prohibited without prior written permission from Wicky.ID.
8
+
9
+ Use of this SDK requires a valid SNAPPY_TOKEN issued by Wicky.ID.
10
+ Unauthorized use will result in immediate token revocation.
11
+
12
+ Contact: hi@wicky.id ยท wicky.id/snappy
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @snappy-stack/sdk ๐Ÿ›ก๏ธ๐Ÿš€
2
+
3
+ A high-performance, secure, and opinionated SDK for the Snappy Stack ecosystem.
4
+
5
+ ## โš–๏ธ License & Proprietary Notice
6
+
7
+ **Copyright (c) 2026 Bagas Fajar Wicaksono (WickyID) / Snappy-Stack. All rights reserved.**
8
+
9
+ This software is **proprietary**. Unauthorized copying, modification, distribution, or build-output tampering is strictly prohibited. By using this SDK, you agree to the terms outlined in the [LICENSE](./LICENSE) file.
10
+
11
+ ---
12
+
13
+ ## ๐Ÿ—๏ธ Installation
14
+
15
+ ```bash
16
+ npm install @snappy-stack/sdk
17
+ # or
18
+ pnpm add @snappy-stack/sdk
19
+ ```
20
+
21
+ ## ๐Ÿš€ Usage
22
+
23
+ ### Snappy Client
24
+ ```typescript
25
+ import { createClient } from '@snappy-stack/sdk';
26
+
27
+ const client = createClient({
28
+ publicKey: 'YOUR_PUBLIC_KEY',
29
+ });
30
+ ```
31
+
32
+ ### Components (React)
33
+ ```tsx
34
+ import { SnappyCredit } from '@snappy-stack/sdk/components';
35
+
36
+ export default function App() {
37
+ return (
38
+ <div>
39
+ <SnappyCredit />
40
+ </div>
41
+ );
42
+ }
43
+ ```
44
+
45
+ ## ๐Ÿ›ก๏ธ Build-time Enforcement
46
+
47
+ This SDK includes a mandatory credit enforcer Vite/Rollup plugin. To ensure compliance and optimal quality scoring, add the plugin to your build configuration:
48
+
49
+ ```typescript
50
+ import { snappyCreditEnforcer } from '@snappy-stack/sdk/plugins';
51
+
52
+ export default {
53
+ plugins: [
54
+ snappyCreditEnforcer()
55
+ ]
56
+ }
57
+ ```
58
+
59
+ ## ๐Ÿ“Š Quality Scoring (SEO/Audit)
60
+
61
+ The SDK automatically evaluates your application against the Snappy Quality Standard, providing real-time feedback on performance, SEO, and integration health.
62
+
63
+ ---
64
+
65
+ Built with โšก by [Snappy-Stack](https://github.com/Snappy-Stack).
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';var jsxRuntime=require('react/jsx-runtime'),f=require('fs'),g=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var f__default=/*#__PURE__*/_interopDefault(f);var g__default=/*#__PURE__*/_interopDefault(g);var u=class{config;constructor(t){this.config={...t,baseUrl:t.baseUrl||"https://core.wicky.id"};}async fetch(t,n={}){let e=`${this.config.baseUrl}${t}`,o={Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json",...n.headers},i=await fetch(e,{...n,headers:o});if(i.status===429)throw new Error("SNAPPY_SDK_E429: Too many requests. Rate limit exceeded.");if(!i.ok){let r=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(`SNAPPY_SDK_E${i.status}: ${r.error||i.statusText}`)}return i.json()}collection(t){return {getAll:(n={})=>{let e=new URLSearchParams({locale:n.locale||this.config.locale||"en",status:n.status||"PUBLISHED",limit:(n.limit||20).toString(),offset:(n.offset||0).toString()}).toString();return this.fetch(`/v1/content/${t}?${e}`)},getOne:(n,e)=>{let o=e||this.config.locale||"en";return this.fetch(`/v1/content/${t}/${n}?locale=${o}`)},getBySlug:(n,e)=>{let o=e||this.config.locale||"en";return this.fetch(`/v1/content/${t}/slug/${n}?locale=${o}`)}}}global(t){return {get:n=>{let e=n||this.config.locale||"en";return this.fetch(`/v1/globals/${t}?locale=${e}`)}}}media={getAll:()=>this.fetch("/v1/media"),getOne:t=>this.fetch(`/v1/media/${t}`)};async heartbeat(){return this.fetch("/v1/heartbeat")}async search(t,n){let e=n||this.config.locale||"en";return this.fetch(`/v1/search?q=${encodeURIComponent(t)}&locale=${e}`)}};function N(s){return new u(s)}var E=()=>jsxRuntime.jsx("div",{className:"snappy-credit py-8 mt-12 border-t border-white/5 text-center",children:jsxRuntime.jsxs("p",{className:"text-[10px] font-mono uppercase tracking-[0.3em] text-white/30",children:["Built with"," ",jsxRuntime.jsx("a",{href:"https://wicky.id/snappy",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent/80 transition-colors",children:"SNAPPY STACK"})," ","by"," ",jsxRuntime.jsx("a",{href:"https://wicky.id",target:"_blank",rel:"noopener noreferrer",className:"hover:text-white/50 transition-colors",children:"wicky.id"})]})});E.snappyMarker="SK_SNAPPY_V2_CREDIT_VERIFIED";function y(s){let t=x(s),n={hardcodedValues:0,missingAltTags:0,missingMetaTags:{title:false,description:false,ogImage:false},unoptimizedImages:0,totalBuildSize:0},e=/#(?:[0-9a-fA-F]{3}){1,2}\b/g,o=/rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/g,i=/hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)/g,r=/<img\s+[^>]*>/gi,m=/alt=(?:["']|\{)/i;for(let a of t){let l=f__default.default.readFileSync(a,"utf8"),b=g__default.default.extname(a);if([".tsx",".jsx",".css",".astro"].includes(b)){let c=l.replace(/:root\s*{[^}]*}/g,"").replace(/@theme\s*{[^}]*}/g,"");c=c.split(`
2
+ `).filter(C=>!C.trim().startsWith("--")).join(`
3
+ `);let w=c.match(e)||[],T=c.match(o)||[],R=c.match(i)||[];n.hardcodedValues+=w.length+T.length+R.length;}if([".tsx",".jsx",".astro"].includes(b)){let c=l.match(r)||[];for(let S of c)m.test(S)||n.missingAltTags++;}(a.toLowerCase().includes("layout")||a.toLowerCase().includes("index.astro"))&&(l.includes("<title>")&&(n.missingMetaTags.title=true),(l.includes('name="description"')||l.includes('property="description"'))&&(n.missingMetaTags.description=true),l.includes('property="og:image"')&&(n.missingMetaTags.ogImage=true));}return n}function x(s,t=[]){return f__default.default.existsSync(s)?(f__default.default.readdirSync(s).forEach(e=>{f__default.default.statSync(g__default.default.join(s,e)).isDirectory()?e!=="node_modules"&&e!==".astro"&&(t=x(g__default.default.join(s,e),t)):t.push(g__default.default.join(s,e));}),t):[]}function $(s){let t={performance:.3,accessibility:.2,seo:.2,compliance:.15,optimization:.1,bundle:.05},n=100-s.missingAltTags*10;n=Math.max(0,n);let e=100-s.missingAltTags*20;e=Math.max(0,e);let o=0;s.missingMetaTags.title&&(o+=40),s.missingMetaTags.description&&(o+=40),s.missingMetaTags.ogImage&&(o+=20);let i=100-s.hardcodedValues*5;i=Math.max(0,i);let r=100,m=100;s.totalBuildSize>10*1024*1024&&(m=40);let a=Math.round(n*t.performance+e*t.accessibility+o*t.seo+i*t.compliance+r*t.optimization+m*t.bundle);return {performance:n,accessibility:e,seo:o,compliance:i,optimization:r,bundle:m,total:a}}function V(){return {name:"snappy-credit-enforcer",async buildStart(){let s=g__default.default.resolve(process.cwd(),"src"),t=A(s),n=false;for(let e of t)if(e.endsWith(".astro")||e.endsWith(".tsx")||e.endsWith(".jsx")){let o=f__default.default.readFileSync(e,"utf8");if(o.includes("SnappyCredit")||o.includes("<SnappyCredit")){n=true;break}}if(!n)throw new Error(`
4
+
5
+ \x1B[31m[SNAPPY_SDK_E401]\x1B[0m
6
+ Build validation failed: Mandatory <SnappyCredit /> component missing.
7
+
8
+ `)},async buildEnd(){let s=g__default.default.resolve(process.cwd(),"src"),t=y(s),n=$(t);n.total<50&&process.exit(1);let e=process.env.SNAPPY_TOKEN,o=process.env.SNAPPY_URL||"https://core.wicky.id";if(e)try{await fetch(`${o}/v1/projects/self/score`,{method:"PATCH",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({score:n.total})});}catch{}}}}function A(s,t=[]){return f__default.default.existsSync(s)?(f__default.default.readdirSync(s).forEach(e=>{f__default.default.statSync(g__default.default.join(s,e)).isDirectory()?e!=="node_modules"&&e!==".astro"&&(t=A(g__default.default.join(s,e),t)):t.push(g__default.default.join(s,e));}),t):[]}
9
+ exports.SnappyClient=u;exports.SnappyCredit=E;exports.createClient=N;exports.snappyCreditEnforcer=V;
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+
3
+ interface SnappyConfig {
4
+ token: string;
5
+ baseUrl?: string;
6
+ locale?: string;
7
+ }
8
+ declare class SnappyClient {
9
+ private config;
10
+ constructor(config: SnappyConfig);
11
+ private fetch;
12
+ collection(slug: string): {
13
+ getAll: (params?: {
14
+ locale?: string;
15
+ status?: string;
16
+ limit?: number;
17
+ offset?: number;
18
+ }) => Promise<any>;
19
+ getOne: (id: string, locale?: string) => Promise<any>;
20
+ getBySlug: (entrySlug: string, locale?: string) => Promise<any>;
21
+ };
22
+ global(slug: string): {
23
+ get: (locale?: string) => Promise<any>;
24
+ };
25
+ media: {
26
+ getAll: () => Promise<any>;
27
+ getOne: (id: string) => Promise<any>;
28
+ };
29
+ heartbeat(): Promise<any>;
30
+ search(query: string, locale?: string): Promise<any>;
31
+ }
32
+ declare function createClient(config: SnappyConfig): SnappyClient;
33
+
34
+ declare const SnappyCredit: React.FC;
35
+
36
+ declare function snappyCreditEnforcer(): {
37
+ name: string;
38
+ buildStart(): Promise<void>;
39
+ buildEnd(): Promise<void>;
40
+ };
41
+
42
+ export { SnappyClient, type SnappyConfig, SnappyCredit, createClient, snappyCreditEnforcer };
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+
3
+ interface SnappyConfig {
4
+ token: string;
5
+ baseUrl?: string;
6
+ locale?: string;
7
+ }
8
+ declare class SnappyClient {
9
+ private config;
10
+ constructor(config: SnappyConfig);
11
+ private fetch;
12
+ collection(slug: string): {
13
+ getAll: (params?: {
14
+ locale?: string;
15
+ status?: string;
16
+ limit?: number;
17
+ offset?: number;
18
+ }) => Promise<any>;
19
+ getOne: (id: string, locale?: string) => Promise<any>;
20
+ getBySlug: (entrySlug: string, locale?: string) => Promise<any>;
21
+ };
22
+ global(slug: string): {
23
+ get: (locale?: string) => Promise<any>;
24
+ };
25
+ media: {
26
+ getAll: () => Promise<any>;
27
+ getOne: (id: string) => Promise<any>;
28
+ };
29
+ heartbeat(): Promise<any>;
30
+ search(query: string, locale?: string): Promise<any>;
31
+ }
32
+ declare function createClient(config: SnappyConfig): SnappyClient;
33
+
34
+ declare const SnappyCredit: React.FC;
35
+
36
+ declare function snappyCreditEnforcer(): {
37
+ name: string;
38
+ buildStart(): Promise<void>;
39
+ buildEnd(): Promise<void>;
40
+ };
41
+
42
+ export { SnappyClient, type SnappyConfig, SnappyCredit, createClient, snappyCreditEnforcer };
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import f from'fs';import g from'path';var u=class{config;constructor(t){this.config={...t,baseUrl:t.baseUrl||"https://core.wicky.id"};}async fetch(t,n={}){let e=`${this.config.baseUrl}${t}`,o={Authorization:`Bearer ${this.config.token}`,"Content-Type":"application/json",...n.headers},i=await fetch(e,{...n,headers:o});if(i.status===429)throw new Error("SNAPPY_SDK_E429: Too many requests. Rate limit exceeded.");if(!i.ok){let r=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(`SNAPPY_SDK_E${i.status}: ${r.error||i.statusText}`)}return i.json()}collection(t){return {getAll:(n={})=>{let e=new URLSearchParams({locale:n.locale||this.config.locale||"en",status:n.status||"PUBLISHED",limit:(n.limit||20).toString(),offset:(n.offset||0).toString()}).toString();return this.fetch(`/v1/content/${t}?${e}`)},getOne:(n,e)=>{let o=e||this.config.locale||"en";return this.fetch(`/v1/content/${t}/${n}?locale=${o}`)},getBySlug:(n,e)=>{let o=e||this.config.locale||"en";return this.fetch(`/v1/content/${t}/slug/${n}?locale=${o}`)}}}global(t){return {get:n=>{let e=n||this.config.locale||"en";return this.fetch(`/v1/globals/${t}?locale=${e}`)}}}media={getAll:()=>this.fetch("/v1/media"),getOne:t=>this.fetch(`/v1/media/${t}`)};async heartbeat(){return this.fetch("/v1/heartbeat")}async search(t,n){let e=n||this.config.locale||"en";return this.fetch(`/v1/search?q=${encodeURIComponent(t)}&locale=${e}`)}};function N(s){return new u(s)}var E=()=>jsx("div",{className:"snappy-credit py-8 mt-12 border-t border-white/5 text-center",children:jsxs("p",{className:"text-[10px] font-mono uppercase tracking-[0.3em] text-white/30",children:["Built with"," ",jsx("a",{href:"https://wicky.id/snappy",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:text-accent/80 transition-colors",children:"SNAPPY STACK"})," ","by"," ",jsx("a",{href:"https://wicky.id",target:"_blank",rel:"noopener noreferrer",className:"hover:text-white/50 transition-colors",children:"wicky.id"})]})});E.snappyMarker="SK_SNAPPY_V2_CREDIT_VERIFIED";function y(s){let t=x(s),n={hardcodedValues:0,missingAltTags:0,missingMetaTags:{title:false,description:false,ogImage:false},unoptimizedImages:0,totalBuildSize:0},e=/#(?:[0-9a-fA-F]{3}){1,2}\b/g,o=/rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/g,i=/hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)/g,r=/<img\s+[^>]*>/gi,m=/alt=(?:["']|\{)/i;for(let a of t){let l=f.readFileSync(a,"utf8"),b=g.extname(a);if([".tsx",".jsx",".css",".astro"].includes(b)){let c=l.replace(/:root\s*{[^}]*}/g,"").replace(/@theme\s*{[^}]*}/g,"");c=c.split(`
2
+ `).filter(C=>!C.trim().startsWith("--")).join(`
3
+ `);let w=c.match(e)||[],T=c.match(o)||[],R=c.match(i)||[];n.hardcodedValues+=w.length+T.length+R.length;}if([".tsx",".jsx",".astro"].includes(b)){let c=l.match(r)||[];for(let S of c)m.test(S)||n.missingAltTags++;}(a.toLowerCase().includes("layout")||a.toLowerCase().includes("index.astro"))&&(l.includes("<title>")&&(n.missingMetaTags.title=true),(l.includes('name="description"')||l.includes('property="description"'))&&(n.missingMetaTags.description=true),l.includes('property="og:image"')&&(n.missingMetaTags.ogImage=true));}return n}function x(s,t=[]){return f.existsSync(s)?(f.readdirSync(s).forEach(e=>{f.statSync(g.join(s,e)).isDirectory()?e!=="node_modules"&&e!==".astro"&&(t=x(g.join(s,e),t)):t.push(g.join(s,e));}),t):[]}function $(s){let t={performance:.3,accessibility:.2,seo:.2,compliance:.15,optimization:.1,bundle:.05},n=100-s.missingAltTags*10;n=Math.max(0,n);let e=100-s.missingAltTags*20;e=Math.max(0,e);let o=0;s.missingMetaTags.title&&(o+=40),s.missingMetaTags.description&&(o+=40),s.missingMetaTags.ogImage&&(o+=20);let i=100-s.hardcodedValues*5;i=Math.max(0,i);let r=100,m=100;s.totalBuildSize>10*1024*1024&&(m=40);let a=Math.round(n*t.performance+e*t.accessibility+o*t.seo+i*t.compliance+r*t.optimization+m*t.bundle);return {performance:n,accessibility:e,seo:o,compliance:i,optimization:r,bundle:m,total:a}}function V(){return {name:"snappy-credit-enforcer",async buildStart(){let s=g.resolve(process.cwd(),"src"),t=A(s),n=false;for(let e of t)if(e.endsWith(".astro")||e.endsWith(".tsx")||e.endsWith(".jsx")){let o=f.readFileSync(e,"utf8");if(o.includes("SnappyCredit")||o.includes("<SnappyCredit")){n=true;break}}if(!n)throw new Error(`
4
+
5
+ \x1B[31m[SNAPPY_SDK_E401]\x1B[0m
6
+ Build validation failed: Mandatory <SnappyCredit /> component missing.
7
+
8
+ `)},async buildEnd(){let s=g.resolve(process.cwd(),"src"),t=y(s),n=$(t);n.total<50&&process.exit(1);let e=process.env.SNAPPY_TOKEN,o=process.env.SNAPPY_URL||"https://core.wicky.id";if(e)try{await fetch(`${o}/v1/projects/self/score`,{method:"PATCH",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({score:n.total})});}catch{}}}}function A(s,t=[]){return f.existsSync(s)?(f.readdirSync(s).forEach(e=>{f.statSync(g.join(s,e)).isDirectory()?e!=="node_modules"&&e!==".astro"&&(t=A(g.join(s,e),t)):t.push(g.join(s,e));}),t):[]}
9
+ export{u as SnappyClient,E as SnappyCredit,N as createClient,V as snappyCreditEnforcer};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@snappy-stack/sdk",
3
+ "version": "0.1.4",
4
+ "engines": {
5
+ "node": "24.x"
6
+ },
7
+ "packageManager": "pnpm@9.15.0",
8
+ "license": "SEE LICENSE IN LICENSE",
9
+ "publishConfig": {
10
+ "registry": "https://registry.npmjs.org/",
11
+ "access": "public"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/Snappy-Stack/Snappy_Stack"
21
+ },
22
+ "type": "module",
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "@types/react": "^19.2.14",
32
+ "tsup": "^8.0.0",
33
+ "typescript": "^5.0.0"
34
+ },
35
+ "dependencies": {
36
+ "react": "^19.2.4"
37
+ }
38
+ }