Git Product home page Git Product logo

node-reminders's Introduction

node-reminders

npm version Build Status codecov

A NodeJS and TypeScript wrapper for the macOS Reminders App.

  • ๐Ÿ”ฅ Easy to use interface to create, retrieve, update and delete lists and reminders
  • ๐Ÿ‘พ CommonJS and ES6 modules
  • ๐Ÿค– Typings available
  • ๐ŸŽฉ JXA-based communication with the Reminders App

Installation

npm i node-reminders

Usage

Use it in JavaScript with CommonJS or in TypeScript with ES6 modules.

// with JavaScript
const reminders = require('node-reminders');

// with TypeScript
import * as reminders from 'node-reminders';

async function run() {
  // get lists
  const lists = await reminders.getLists();

  // create reminder
  const laterToday = new Date();
  laterToday.setHours(laterToday.getHours() + 8);

  reminders.createReminder(lists[0].id, {
    name: 'Call John',
    body: 'Catch up on the plan',
    remindMeDate: laterToday,
  });
}

API

getLists(): Promise<List[]>

Resolves with the list of reminders lists.

getList(id: string): Promise<List>

Resolves with the detail of a specific list.

createList(data: List): Promise<string>

Creates a new reminders list and resolves with its ID.

getReminders(listId: string, props?: Array<keyof Reminder>): Promise<Reminder[]>

Resolves with the reminders of a given list. Optionally specify which props to retrieve. The more props, the slower the query. See the reminders example for more.

getReminder(reminderId: string, props?: Array<keyof Reminder>): Promise<Reminder>

Resolves with the information of a specific reminder. Optionally specify which props to retrieve.

updateReminder(id: string, data: Partial<Reminder>): Promise<string>

Updates a reminder and resolves with its ID. Pass only the subset of parameters to modify.

deleteReminder(id: string): Promise<true>

Deletes a reminder and resolves with true if successful. Throws exception otherwise.

createReminder(listId: string, data: Partial<Reminder>): Promise<string>

Creates a reminder in a list and resolves with its ID. See example.

Examples

List

Get Lists

import { getLists } from 'node-reminders';

(async () => {
  const lists = await getLists();
  console.log(lists);

  /**
   * [
   *  { name: 'Reminders', id: '2480C298-017A-11EB-BBBF-CB4F4FDF3602' },
   *  { name: 'Family TODO', id: '3D8660F9-9925-461A-B5FB-B0DDD56B7925' }
   * ]
   */
})();

Get List

import { getList } from 'node-reminders';

(async () => {
  const list = await getList('2480C298-017A-11EB-BBBF-CB4F4FDF3602');
  console.log(list);

  /**
   * { name: 'Reminders', id: '2480C298-017A-11EB-BBBF-CB4F4FDF3602' }
   */
})();

Create List

import { createList } from 'node-reminders';

(async () => {
  const newList = await createList({ name: 'June Reminders' });
  console.log(newList);

  /**
   * '8AE21B5E-466A-4FDA-B59B-10B8CC80418A'
   */
})();

Note: List deletion is not supported. It's simply not allowed either via .jxa or .applescript directly.

Reminders

Get reminders

import { getReminders } from 'node-reminders';

(async () => {
  const reminderList = await getReminders(
    '2480C298-017A-11EB-BBBF-CB4F4FDF3602',
    [ 'name', 'id', 'remindMeDate', 'completed', 'priority' ] // fetch only a subset of properties
  );
  console.log(reminderList);

  /**
      [
        { name: 'Call John',
          id: 'x-apple-reminder://776E5676-BB79-4095-8317-C94863814B50',
          remindMeDate: '2020-04-13T15:02:34.000Z',
          completed: true,
          priority: 0 },
        { name: 'Pay the bills',
          id: 'x-apple-reminder://8D9A728B-24C3-420B-A664-352B3C06E689',
          remindMeDate: '2025-04-15T15:09:08.000Z',
          completed: false,
          priority: 0 },
        { name: 'Ping Lina',
          id: 'x-apple-reminder://6C6D0961-B80D-4967-A9D6-B73F8278A117',
          remindMeDate: null,
          completed: false,
          priority: 0 },
      ]
   */
})();

Get reminder

import { getReminder } from 'node-reminders';

(async () => {
  const reminder = await getReminder(
    'x-apple-reminder://8D9A728B-24C3-420B-A664-352B3C06E689',
    ['name', 'remindMeDate', 'completed']
  );
  console.log(reminder);

  /**
    {
      name: 'Pay the bills',
      remindMeDate: '2025-04-15T15:09:08.000Z',
      completed: false
    }
   */
})();

Update reminder

import { updateReminder } from 'node-reminders';

(async () => {
  const oneMonthLater = new Date();
  oneMonthLater.setFullYear(oneMonthLater.getMonth() + 1);

  const edited = await reminders.updateReminder(
    'x-apple-reminder://8D9A728B-24C3-420B-A664-352B3C06E689',
    {
      name: 'Pay cable',
      completed: true,
      remindMeDate: oneMonthLater,
    }
  );
  console.log(edited);

  /**
   * 'x-apple-reminder://8D9A728B-24C3-420B-A664-352B3C06E689'
   */
})();

Delete reminder

import { deleteReminder } from 'node-reminders';

(async () => {
  try {
    const deletedReminder = await reminders.deleteReminder('2480C298-017A-11EB-BBBF-CB4F4FDF3602');
    console.log(deleteReminder);
  } catch(e) {
    console.error('Something failed. Could not delete the reminder.');
  }

  /**
   * true
   */
})();

Create reminder

import { createReminder } from 'node-reminders';

(async () => {
  const laterToday = new Date();
  laterToday.setHours(laterToday.getHours() + 8);

  const newReminder = await createReminder(
    '2480C298-017A-11EB-BBBF-CB4F4FDF3602',
    {
      name: 'Update daily journal',
      body: 'Lots of things going on',
      remindMeDate: laterToday,
      completed: false,
  });
  console.log(newReminder);

  /**
   * 'x-apple-reminder://32E91818-16FB-4E89-9C36-4960207AEA12
   */
})();

Interfaces

The interface prop names are self-explanatory. Descriptions are intentionally omitted.

List

Param Type
name string
id string

Reminder

Param Type
name string
body string
id string
complete boolean
completionDate Date
creationDate Date
dueDate Date
modificationDate Date
remindMeDate Date
priority number

How it works

Under the hood, this library is an interface to run JXA scripts in the terminal. JXA is JavaScript for OSX automation. You can find all the scripts in src/jxa. Arguments and outputs are passed back and forth via stringified objects.

Licence

MIT ยฉ Carlos Roso

node-reminders's People

Contributors

caroso1222 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

node-reminders's Issues

URL seems to be inaccessible

  • I'm submitting a ...
    [ ] bug report
    [x] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

I think URL is a relatively newer field. My code looks like this:

// with JavaScript
const reminders = require("node-reminders");

async function run() {
  // get lists
  // const lists = await reminders.getLists();
  // const list = await reminders.getList("EBF92994-1DF8-47C5-B318-BA9228C13D9C");
  const listOfReminders = await reminders.getReminders(
    "EBF92994-1DF8-47C5-B318-BA9228C13D9C",
    ["name", "remindMeDate", "completed", "body"]
  );
  console.dir(listOfReminders);
}

run();

But when I try to add the url field it gives me an error.

/Users/jhart/workspace/instagram-recipe-extractor/node_modules/execa/lib/error.js:59
                error = new Error(message);
                        ^

Error: Command failed with exit code 1: osascript -l JavaScript /Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/jxa/get-reminders.jxa {"id":"EBF92994-1DF8-47C5-B318-BA9228C13D9C","props":["name","remindMeDate","completed","body","URL"]}
/Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/jxa/get-reminders.jxa: execution error: Error: Error: Can't get object. (-1728)
    at makeError (/Users/jhart/workspace/instagram-recipe-extractor/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/Users/jhart/workspace/instagram-recipe-extractor/node_modules/execa/index.js:114:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.execJXA (/Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/lib/utils.js:31:24)
    at async Object.getReminders (/Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/lib/reminders.js:20:23)
    at async run (/Users/jhart/workspace/instagram-recipe-extractor/bin/main.js:8:27) {
  shortMessage: 'Command failed with exit code 1: osascript -l JavaScript /Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/jxa/get-reminders.jxa {"id":"EBF92994-1DF8-47C5-B318-BA9228C13D9C","props":["name","remindMeDate","completed","body","URL"]}',
  command: 'osascript -l JavaScript /Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/jxa/get-reminders.jxa {"id":"EBF92994-1DF8-47C5-B318-BA9228C13D9C","props":["name","remindMeDate","completed","body","URL"]}',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: "/Users/jhart/workspace/instagram-recipe-extractor/node_modules/node-reminders/build/main/jxa/get-reminders.jxa: execution error: Error: Error: Can't get object. (-1728)",
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

I've tried url, uri, URL, link... Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.