@masa-dev/gas-line 0.0.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.
@@ -0,0 +1,6 @@
1
+ import { UserProfile } from './types';
2
+ export declare class LineClient {
3
+ private channelAccessToken;
4
+ constructor(channelAccessToken: string);
5
+ getUserProfile(userId: string): UserProfile;
6
+ }
@@ -0,0 +1,12 @@
1
+ export class LineClient {
2
+ constructor(channelAccessToken) {
3
+ this.channelAccessToken = channelAccessToken;
4
+ }
5
+ getUserProfile(userId) {
6
+ const url = `https://api.line.me/v2/bot/profile/${userId}`;
7
+ const response = UrlFetchApp.fetch(url, {
8
+ headers: { Authorization: `Bearer ${this.channelAccessToken}` },
9
+ });
10
+ return JSON.parse(response.getContentText());
11
+ }
12
+ }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,7 @@
1
+ import { GasDoPostEvent, WebhookData } from './types';
2
+ export * from './types';
3
+ export * from './types.base';
4
+ export * from './types.message';
5
+ export * from './types.others';
6
+ export * from './LineClient';
7
+ export declare function parsePostEvent(e: GasDoPostEvent): WebhookData;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './types';
2
+ export * from './types.base';
3
+ export * from './types.message';
4
+ export * from './types.others';
5
+ export * from './LineClient';
6
+ export function parsePostEvent(e) {
7
+ return JSON.parse(e.postData.contents);
8
+ }
@@ -0,0 +1,24 @@
1
+ export interface Event {
2
+ type: 'message' | 'follow' | 'unfollow' | 'join' | 'leave' | 'postback' | 'beacon';
3
+ mode: 'active' | 'standby';
4
+ timestamp: number;
5
+ source?: SourceUser | SourceGroup | SourceRoom;
6
+ webhookEventId: string;
7
+ deliveryContext: {
8
+ isRedelivery: boolean;
9
+ };
10
+ }
11
+ export interface SourceUser {
12
+ type: 'user';
13
+ userId: string;
14
+ }
15
+ export interface SourceGroup {
16
+ type: 'group';
17
+ groupId: string;
18
+ userId?: string;
19
+ }
20
+ export interface SourceRoom {
21
+ type: 'room';
22
+ roomId: string;
23
+ userId?: string;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { MessageEvent } from './types.message';
2
+ import { OtherEvent } from './types.others';
3
+ export interface WebhookData {
4
+ destination: string;
5
+ events: (MessageEvent | OtherEvent)[];
6
+ }
7
+ export interface GasDoPostEvent {
8
+ contextPath: string;
9
+ parameters: Record<string, any>;
10
+ parameter: Record<string, any>;
11
+ queryString: string;
12
+ contentLength: number;
13
+ postData: {
14
+ contents: string;
15
+ length: number;
16
+ name: string;
17
+ type: string;
18
+ };
19
+ }
20
+ export interface UserProfile {
21
+ displayName: string;
22
+ userId: string;
23
+ language?: string;
24
+ pictureUrl?: string;
25
+ statusMessage?: string;
26
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { Event } from './types.base';
2
+ export interface MessageEvent extends Event {
3
+ type: 'message';
4
+ replyToken: string;
5
+ message: TextMessage | OtherMessage;
6
+ }
7
+ export interface Message {
8
+ id: string;
9
+ type: 'text' | 'image' | 'video' | 'audio' | 'file' | 'location' | 'sticker';
10
+ }
11
+ export interface TextMessage extends Message {
12
+ type: 'text';
13
+ quoteToken: string;
14
+ text: string;
15
+ emojis?: any[];
16
+ }
17
+ export interface OtherMessage extends Message {
18
+ type: 'image' | 'video' | 'audio' | 'file' | 'location' | 'sticker';
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Event } from './types.base';
2
+ export interface OtherEvent extends Event {
3
+ type: 'follow' | 'unfollow' | 'join' | 'leave' | 'postback' | 'beacon';
4
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@masa-dev/gas-line",
3
+ "version": "0.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Line tools for Google Apps Script",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/mohhh-ok/gas-line"
13
+ },
14
+ "keywords": [
15
+ "gas",
16
+ "line",
17
+ "google apps script"
18
+ ],
19
+ "license": "MIT",
20
+ "devDependencies": {
21
+ "@types/google-apps-script": "^1.0.91"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc",
25
+ "dev": "tsc --watch"
26
+ }
27
+ }
@@ -0,0 +1,13 @@
1
+ import { UserProfile } from './types';
2
+
3
+ export class LineClient {
4
+ constructor(private channelAccessToken: string) {}
5
+
6
+ getUserProfile(userId: string): UserProfile {
7
+ const url = `https://api.line.me/v2/bot/profile/${userId}`;
8
+ const response = UrlFetchApp.fetch(url, {
9
+ headers: { Authorization: `Bearer ${this.channelAccessToken}` },
10
+ });
11
+ return JSON.parse(response.getContentText());
12
+ }
13
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { GasDoPostEvent, WebhookData } from './types';
2
+ export * from './types';
3
+ export * from './types.base';
4
+ export * from './types.message';
5
+ export * from './types.others';
6
+ export * from './LineClient';
7
+
8
+ export function parsePostEvent(e: GasDoPostEvent): WebhookData {
9
+ return JSON.parse(e.postData.contents);
10
+ }
@@ -0,0 +1,34 @@
1
+ export interface Event {
2
+ type:
3
+ | 'message'
4
+ | 'follow'
5
+ | 'unfollow'
6
+ | 'join'
7
+ | 'leave'
8
+ | 'postback'
9
+ | 'beacon';
10
+ mode: 'active' | 'standby';
11
+ timestamp: number;
12
+ source?: SourceUser | SourceGroup | SourceRoom;
13
+ webhookEventId: string;
14
+ deliveryContext: {
15
+ isRedelivery: boolean;
16
+ };
17
+ }
18
+
19
+ export interface SourceUser {
20
+ type: 'user';
21
+ userId: string;
22
+ }
23
+
24
+ export interface SourceGroup {
25
+ type: 'group';
26
+ groupId: string;
27
+ userId?: string;
28
+ }
29
+
30
+ export interface SourceRoom {
31
+ type: 'room';
32
+ roomId: string;
33
+ userId?: string;
34
+ }
@@ -0,0 +1,23 @@
1
+ import { Event } from './types.base';
2
+
3
+ export interface MessageEvent extends Event {
4
+ type: 'message';
5
+ replyToken: string;
6
+ message: TextMessage | OtherMessage;
7
+ }
8
+
9
+ export interface Message {
10
+ id: string;
11
+ type: 'text' | 'image' | 'video' | 'audio' | 'file' | 'location' | 'sticker';
12
+ }
13
+
14
+ export interface TextMessage extends Message {
15
+ type: 'text';
16
+ quoteToken: string;
17
+ text: string;
18
+ emojis?: any[];
19
+ }
20
+
21
+ export interface OtherMessage extends Message {
22
+ type: 'image' | 'video' | 'audio' | 'file' | 'location' | 'sticker';
23
+ }
@@ -0,0 +1,5 @@
1
+ import { Event } from './types.base';
2
+
3
+ export interface OtherEvent extends Event {
4
+ type: 'follow' | 'unfollow' | 'join' | 'leave' | 'postback' | 'beacon';
5
+ }
package/src/types.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { Event } from './types.base';
2
+ import { MessageEvent } from './types.message';
3
+ import { OtherEvent } from './types.others';
4
+
5
+ export interface WebhookData {
6
+ destination: string;
7
+ events: (MessageEvent | OtherEvent)[];
8
+ }
9
+
10
+ export interface GasDoPostEvent {
11
+ contextPath: string;
12
+ parameters: Record<string, any>;
13
+ parameter: Record<string, any>;
14
+ queryString: string;
15
+ contentLength: number;
16
+ postData: {
17
+ contents: string;
18
+ length: number;
19
+ name: string;
20
+ type: string;
21
+ };
22
+ }
23
+
24
+ export interface UserProfile {
25
+ displayName: string;
26
+ userId: string;
27
+ language?: string;
28
+ pictureUrl?: string;
29
+ statusMessage?: string;
30
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "strict": true,
5
+ "outDir": "./dist",
6
+ "rootDir": "./src",
7
+ "declaration": true,
8
+ "lib": [
9
+ "ES2020"
10
+ ]
11
+ },
12
+ "include": [
13
+ "src/**/*"
14
+ ]
15
+ }