@ariadng/sheets 0.1.1 → 0.3.0

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.
Files changed (72) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +453 -299
  3. package/bin/sheets.js +3 -0
  4. package/dist/api/index.d.ts +31 -0
  5. package/dist/api/index.d.ts.map +1 -0
  6. package/dist/api/index.js +87 -0
  7. package/dist/api/index.js.map +1 -0
  8. package/dist/auth/constants.d.ts +13 -0
  9. package/dist/auth/constants.d.ts.map +1 -0
  10. package/dist/auth/constants.js +21 -0
  11. package/dist/auth/constants.js.map +1 -0
  12. package/dist/auth/index.d.ts +13 -0
  13. package/dist/auth/index.d.ts.map +1 -0
  14. package/dist/auth/index.js +22 -0
  15. package/dist/auth/index.js.map +1 -0
  16. package/dist/auth/oauth.d.ts +11 -0
  17. package/dist/auth/oauth.d.ts.map +1 -0
  18. package/dist/auth/oauth.js +14 -0
  19. package/dist/auth/oauth.js.map +1 -0
  20. package/dist/auth/service-account.d.ts +18 -0
  21. package/dist/auth/service-account.d.ts.map +1 -0
  22. package/dist/auth/service-account.js +92 -0
  23. package/dist/auth/service-account.js.map +1 -0
  24. package/dist/auth/user-auth.d.ts +24 -0
  25. package/dist/auth/user-auth.d.ts.map +1 -0
  26. package/dist/auth/user-auth.js +230 -0
  27. package/dist/auth/user-auth.js.map +1 -0
  28. package/dist/cli.d.ts +7 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +412 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/http/index.d.ts +19 -0
  33. package/dist/http/index.d.ts.map +1 -0
  34. package/dist/http/index.js +68 -0
  35. package/dist/http/index.js.map +1 -0
  36. package/dist/index.d.ts +11 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +12 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/types/index.d.ts +133 -0
  41. package/dist/types/index.d.ts.map +1 -0
  42. package/dist/types/index.js +16 -0
  43. package/dist/types/index.js.map +1 -0
  44. package/package.json +58 -79
  45. package/dist/advanced/index.d.ts +0 -5
  46. package/dist/advanced/index.d.ts.map +0 -1
  47. package/dist/advanced/index.js +0 -1063
  48. package/dist/advanced/index.mjs +0 -1005
  49. package/dist/advanced/metrics.d.ts +0 -50
  50. package/dist/advanced/metrics.d.ts.map +0 -1
  51. package/dist/advanced/rate-limit.d.ts +0 -27
  52. package/dist/advanced/rate-limit.d.ts.map +0 -1
  53. package/dist/core/auth.d.ts +0 -33
  54. package/dist/core/auth.d.ts.map +0 -1
  55. package/dist/core/client.d.ts +0 -35
  56. package/dist/core/client.d.ts.map +0 -1
  57. package/dist/core/errors.d.ts +0 -11
  58. package/dist/core/errors.d.ts.map +0 -1
  59. package/dist/core/index.d.ts +0 -6
  60. package/dist/core/index.d.ts.map +0 -1
  61. package/dist/core/index.js +0 -315
  62. package/dist/core/index.mjs +0 -271
  63. package/dist/plus/batch.d.ts +0 -25
  64. package/dist/plus/batch.d.ts.map +0 -1
  65. package/dist/plus/cache.d.ts +0 -19
  66. package/dist/plus/cache.d.ts.map +0 -1
  67. package/dist/plus/index.d.ts +0 -7
  68. package/dist/plus/index.d.ts.map +0 -1
  69. package/dist/plus/index.js +0 -742
  70. package/dist/plus/index.mjs +0 -691
  71. package/dist/plus/types.d.ts +0 -39
  72. package/dist/plus/types.d.ts.map +0 -1
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Google Sheets API Type Definitions
3
+ */
4
+ export interface GridProperties {
5
+ rowCount: number;
6
+ columnCount: number;
7
+ frozenRowCount?: number;
8
+ frozenColumnCount?: number;
9
+ hideGridlines?: boolean;
10
+ }
11
+ export interface SheetProperties {
12
+ sheetId: number;
13
+ title: string;
14
+ index: number;
15
+ sheetType?: 'GRID' | 'OBJECT' | 'DATA_SOURCE';
16
+ gridProperties?: GridProperties;
17
+ hidden?: boolean;
18
+ rightToLeft?: boolean;
19
+ }
20
+ export interface SpreadsheetProperties {
21
+ title: string;
22
+ locale?: string;
23
+ timeZone?: string;
24
+ autoRecalc?: 'ON_CHANGE' | 'MINUTE' | 'HOUR';
25
+ defaultFormat?: CellFormat;
26
+ }
27
+ export interface Spreadsheet {
28
+ spreadsheetId: string;
29
+ properties: SpreadsheetProperties;
30
+ sheets: {
31
+ properties: SheetProperties;
32
+ }[];
33
+ spreadsheetUrl?: string;
34
+ }
35
+ export interface CellFormat {
36
+ numberFormat?: {
37
+ type: string;
38
+ pattern?: string;
39
+ };
40
+ backgroundColor?: Color;
41
+ textFormat?: TextFormat;
42
+ }
43
+ export interface Color {
44
+ red?: number;
45
+ green?: number;
46
+ blue?: number;
47
+ alpha?: number;
48
+ }
49
+ export interface TextFormat {
50
+ foregroundColor?: Color;
51
+ fontFamily?: string;
52
+ fontSize?: number;
53
+ bold?: boolean;
54
+ italic?: boolean;
55
+ strikethrough?: boolean;
56
+ underline?: boolean;
57
+ }
58
+ export interface CellValue {
59
+ value: string | number | boolean | null;
60
+ formula?: string;
61
+ formattedValue?: string;
62
+ }
63
+ export type ValueRenderOption = 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA';
64
+ export type DateTimeRenderOption = 'SERIAL_NUMBER' | 'FORMATTED_STRING';
65
+ export type MajorDimension = 'ROWS' | 'COLUMNS';
66
+ export interface ValueRange {
67
+ range: string;
68
+ majorDimension: MajorDimension;
69
+ values: CellValue[][];
70
+ }
71
+ export interface GetValuesOptions {
72
+ valueRenderOption?: ValueRenderOption;
73
+ dateTimeRenderOption?: DateTimeRenderOption;
74
+ majorDimension?: MajorDimension;
75
+ }
76
+ export interface BatchGetValuesResponse {
77
+ spreadsheetId: string;
78
+ valueRanges: ValueRange[];
79
+ }
80
+ export interface OAuthConfig {
81
+ type: 'oauth';
82
+ accessToken: string;
83
+ refreshToken?: string;
84
+ clientId?: string;
85
+ clientSecret?: string;
86
+ }
87
+ export interface ServiceAccountConfig {
88
+ type: 'service-account';
89
+ credentialsPath?: string;
90
+ credentials?: ServiceAccountCredentials;
91
+ }
92
+ export interface ServiceAccountCredentials {
93
+ type: 'service_account';
94
+ project_id: string;
95
+ private_key_id: string;
96
+ private_key: string;
97
+ client_email: string;
98
+ client_id: string;
99
+ auth_uri: string;
100
+ token_uri: string;
101
+ }
102
+ export interface UserAuthConfig {
103
+ type: 'user';
104
+ }
105
+ export interface StoredTokens {
106
+ accessToken: string;
107
+ refreshToken: string;
108
+ expiresAt: number;
109
+ email?: string;
110
+ }
111
+ export type AuthConfig = OAuthConfig | ServiceAccountConfig | UserAuthConfig;
112
+ export interface SheetsClientOptions {
113
+ auth: AuthConfig;
114
+ }
115
+ export interface SheetsApiErrorDetail {
116
+ '@type'?: string;
117
+ reason?: string;
118
+ domain?: string;
119
+ metadata?: Record<string, string>;
120
+ }
121
+ export interface SheetsApiError {
122
+ code: number;
123
+ message: string;
124
+ status: string;
125
+ details?: SheetsApiErrorDetail[];
126
+ }
127
+ export declare class SheetsError extends Error {
128
+ code: number;
129
+ status: string;
130
+ details?: SheetsApiErrorDetail[];
131
+ constructor(error: SheetsApiError);
132
+ }
133
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,cAAc;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAID,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,MAAM,CAAC,EA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,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,oBAAoB,GAAG,cAAc,CAAC;AAE7E,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,UAAU,CAAC;CACpB;AAID,MAAM,WAAW,oBAAoB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACpC;AAED,qBAAa,WAAY,SAAQ,KAAK;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;gBAErB,KAAK,EAAE,cAAc;CAOpC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Google Sheets API Type Definitions
3
+ */
4
+ export class SheetsError extends Error {
5
+ code;
6
+ status;
7
+ details;
8
+ constructor(error) {
9
+ super(error.message);
10
+ this.name = 'SheetsError';
11
+ this.code = error.code;
12
+ this.status = error.status;
13
+ this.details = error.details;
14
+ }
15
+ }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgKH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClC,IAAI,CAAS;IACb,MAAM,CAAS;IACf,OAAO,CAA0B;IAEjC,YAAY,KAAqB;QAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IACjC,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,81 +1,60 @@
1
1
  {
2
- "name": "@ariadng/sheets",
3
- "version": "0.1.1",
4
- "description": "A pragmatic TypeScript client for Google Sheets API v4",
5
- "main": "./dist/core/index.js",
6
- "module": "./dist/core/index.mjs",
7
- "types": "./dist/core/index.d.ts",
8
- "exports": {
9
- "./core": {
10
- "types": "./dist/core/index.d.ts",
11
- "import": "./dist/core/index.mjs",
12
- "require": "./dist/core/index.js"
13
- },
14
- "./plus": {
15
- "types": "./dist/plus/index.d.ts",
16
- "import": "./dist/plus/index.mjs",
17
- "require": "./dist/plus/index.js"
18
- },
19
- "./advanced": {
20
- "types": "./dist/advanced/index.d.ts",
21
- "import": "./dist/advanced/index.mjs",
22
- "require": "./dist/advanced/index.js"
23
- }
24
- },
25
- "scripts": {
26
- "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types",
27
- "build:esm": "esbuild src/*/index.ts --bundle --platform=node --format=esm --outdir=dist --out-extension:.js=.mjs --external:googleapis --external:google-auth-library",
28
- "build:cjs": "esbuild src/*/index.ts --bundle --platform=node --format=cjs --outdir=dist --external:googleapis --external:google-auth-library",
29
- "build:types": "tsc --emitDeclarationOnly --declaration",
30
- "clean": "rm -rf dist",
31
- "test": "jest",
32
- "test:unit": "jest --testPathIgnorePatterns=integration.test.ts",
33
- "test:watch": "jest --watch",
34
- "test:coverage": "jest --coverage",
35
- "lint": "eslint src/**/*.ts",
36
- "format": "prettier --write src/**/*.ts",
37
- "typecheck": "tsc --noEmit",
38
- "dev": "npm run build -- --watch",
39
- "prepublishOnly": "npm run build && npm run test:unit && npm run typecheck"
40
- },
41
- "keywords": [
42
- "google-sheets",
43
- "google",
44
- "sheets",
45
- "spreadsheet",
46
- "api",
47
- "typescript"
48
- ],
49
- "author": "ariadng",
50
- "license": "MIT",
51
- "dependencies": {
52
- "googleapis": "^144.0.0",
53
- "google-auth-library": "^9.15.0"
54
- },
55
- "devDependencies": {
56
- "@types/jest": "^29.5.14",
57
- "@types/node": "^22.10.2",
58
- "@typescript-eslint/eslint-plugin": "^8.18.0",
59
- "@typescript-eslint/parser": "^8.18.0",
60
- "esbuild": "^0.24.0",
61
- "eslint": "^9.17.0",
62
- "jest": "^29.7.0",
63
- "prettier": "^3.4.2",
64
- "ts-jest": "^29.2.5",
65
- "ts-node": "^10.9.2",
66
- "typescript": "^5.7.2"
67
- },
68
- "files": [
69
- "dist",
70
- "README.md",
71
- "LICENSE"
72
- ],
73
- "repository": {
74
- "type": "git",
75
- "url": "https://github.com/ariadng/sheets.git"
76
- },
77
- "bugs": {
78
- "url": "https://github.com/ariadng/sheets/issues"
79
- },
80
- "homepage": "https://github.com/ariadng/sheets#readme"
2
+ "name": "@ariadng/sheets",
3
+ "version": "0.3.0",
4
+ "description": "Google Sheets CLI and API client. Read spreadsheet data from the command line or Node.js. No external SDK required.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "sheets": "bin/sheets.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "bin",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "dev": "tsx watch src/cli.ts",
25
+ "start": "node dist/cli.js",
26
+ "test": "echo \"No tests yet\" && exit 0",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "keywords": [
30
+ "google-sheets",
31
+ "google",
32
+ "sheets",
33
+ "spreadsheet",
34
+ "api",
35
+ "cli",
36
+ "command-line",
37
+ "oauth",
38
+ "service-account",
39
+ "read",
40
+ "data"
41
+ ],
42
+ "author": "Aria Dhanang",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/ariadng/sheets.git"
47
+ },
48
+ "homepage": "https://github.com/ariadng/sheets#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/ariadng/sheets/issues"
51
+ },
52
+ "engines": {
53
+ "node": ">=18.0.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^22.0.0",
57
+ "tsx": "^4.0.0",
58
+ "typescript": "^5.0.0"
59
+ }
81
60
  }
@@ -1,5 +0,0 @@
1
- export { AdaptiveRateLimiter, TokenBucketRateLimiter, withAdaptiveRateLimit, withTokenBucketRateLimit, } from './rate-limit';
2
- export { MetricsCollector, PerformanceMonitor, withMetrics, } from './metrics';
3
- export type { Metrics } from './metrics';
4
- export * from '../plus';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/advanced/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,cAAc,SAAS,CAAC"}